Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有框架代码,用户指定一个scripts.txt包含服务名称的文件。每当安装应用程序时,代码.service都会自动为scripts.txt. 这些服务被放置在 中/lib/systemd/system,因此每当机器崩溃时,应用程序就会重新启动。
scripts.txt
.service
/lib/systemd/system
我想添加一个卸载功能来删除.service创建的文件。为此,代码必须再次查看scripts.txt,但如果用户同时更改了此文件,应用程序将不知道要删除哪些服务。
因此,我想知道,是否有办法在某个进程运行时锁定文件不被编辑?