当前位置: 技术问答>linux和unix
请问如何阻止运行同一程序的多个实例?
来源: 互联网 发布时间:2015-03-21
本文导语: 另外,怎样判断一个FIFO已经读打开? 情形是:该FIFO已经写打开,并向管道写数据;此时另一个进程可以读打开该管道并读取数据;但要是再执行一个进程读打开管道,则两个读进程都读不到数据且阻塞 ...
另外,怎样判断一个FIFO已经读打开?
情形是:该FIFO已经写打开,并向管道写数据;此时另一个进程可以读打开该管道并读取数据;但要是再执行一个进程读打开管道,则两个读进程都读不到数据且阻塞
情形是:该FIFO已经写打开,并向管道写数据;此时另一个进程可以读打开该管道并读取数据;但要是再执行一个进程读打开管道,则两个读进程都读不到数据且阻塞
|
加信号量同步
|
文件锁
|
Traditional solution of this problem is to create a xxxx.pid file. In program you create this file and use a file I/O lock to lock the file (lock to record), and put your pid into the file. Next time if the same executable try to lock the file, it will get failed, therefore it knows that another instance is already running.
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。