[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: waiting for other process..
On Wed, 21 Oct 1998, Oron Peled wrote:
> On 21-Oct-98 Ze'ev Maor wrote:
> > How can I wait under sh (not wait() ) for a process that isn't in the
> > context of the shell that called the wait ??
> Only parent process can wait/waitpid/wait3/wait4() for a child
> process (even if you use C without the sh(1) limitations).
> However, if you only want to coordinate some activity between
> two processes you can use:
> 1. signals (usually bad idea, but accessible from sh(1)
> via kill/trap..
> 2. Some other IPC like named-pipes which are accessible
> from sh(1). You can write some info in the one end
> and block on reading the other end.
In the shell-only programming world, and without making assumptions, you
can have the process to be controlled announce its PID by making a lock
file named such as:
/tmp/I_am_it.1234
for which the controlling program looks to find it. The directory where
you put the tmp file needs to be readable by the controller. the controlee
deletes the lock when it exits. This makes no assumptions on whether or
not the system has IPC at all. The files generated are unique over a
session (no 2 procs have the same PID). Stale locks are to be deleted at
boot time or during crash recovery or else bad things will happen.
Peter