[lkml]   [2001]   [Jan]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: Off-Topic: how do I trace a PID over double-forks?

On Fri, 19 Jan 2001, Felix von Leitner wrote:
> Now, the back channel for my init has a function that allows to set the
> PID of a process. The idea is that the init does not start sendmail but
> a wrapper. The wrapper forks, runs sendmail, does some magic trickery
> to find the real PID of the daemonized sendmail and tells init this PID
> so init will know it has to restart sendmail when it exits and won't
> restart the wrapper when that exits.

> Someone suggested using fcntl to create a lock and then use fcntl again
> to see who holds the lock. That sounded good at first, but fork() does
> not seem to inherit locks. Does anyone have another idea?

Take a look at fghack ( It
opens a pipe, gives the write end to the daemon (but the daemon is not
aware of that) and monitors the read end. When the daemon process
exits, the read end of the pipe gets EOF.

If the daemon closes all filehandles, you're out of luck.


Eric Lammerts <> | The best way to accelerate a computer | running Windows is at 9.8 m/s^2.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
Please read the FAQ at

 \ /
  Last update: 2005-03-22 12:57    [W:0.030 / U:0.304 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site