bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to write a proper fork hook code?


From: Samuel Thibault
Subject: Re: How to write a proper fork hook code?
Date: Mon, 2 Mar 2015 10:09:04 +0100
User-agent: Mutt/1.5.21+34 (58baf7c9f32f) (2010-12-30)

Svante Signell, le Mon 02 Mar 2015 08:29:55 +0100, a écrit :
> Well the basic problem is of course to detect processes generated by
> fork(2).

??

> Is it possible to find those processes having PID 0, generated from
> fork, e.g. with proc_getallpids() ?

??

> Or are they getting a PID>0 with subsequent calls to exec*?

??

I guess you need to read again some handbook about Unix' fork(): it just
creates a second process.  The original process is still there (the
parent), and its fork() call returns the pid of the second process. The
new process (the child), the fork() call returns 0.  There's no hidden
process in there, and the fork hook should get you done.

But again, I'm still unsure why you believe that locks are being
inherited through fork(): before introducing a fork hook to forcibly
unlock something, one needs to be absolutely sure that it's actually
locked.  Actually it'd even look like a design flaw if two process could
actually hold a lock on the same piece of a file...

Samuel



reply via email to

[Prev in Thread] Current Thread [Next in Thread]