简体   繁体   中英

Portable way to wait for process to open file?

Is there a way in Linux, that's reasonably portable (mainly to OSX/BSDs) to wait for a process to open a file? I know I can use inotify for this, but OSX doesn't support it. One caveat is that I won't actually know the PID of the process, so it's exec()-ed via /bin/sh like popen, so just monitoring it's /proc//fd directory won't work either.

There are several available libraries or command-line tools suitable for this purpose with backends that span Linux and MacOS.

Consider fswatch , or one of its competitors (if we got down to debating individual libraries, this would be in explicitly-off-topic territory).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM