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: Svante Signell
Subject: Re: How to write a proper fork hook code?
Date: Mon, 02 Mar 2015 08:29:55 +0100

On Mon, 2015-03-02 at 00:34 +0100, Samuel Thibault wrote:
> Svante Signell, le Mon 02 Mar 2015 00:15:14 +0100, a écrit :
> > On Sun, 2015-03-01 at 23:08 +0100, Svante Signell wrote:
> > > On Sun, 2015-03-01 at 22:06 +0100, Samuel Thibault wrote:
> > 
> > Much simpler code: It only opens a file and calls fork!
> > FCNTL_CALLS version triggers the hook
> > RPC_CALLS version does not
> 
> > #ifdef RPC_CALLS
> >   fd2 = file_name_lookup (argv[1], O_READ | O_WRITE | O_CREAT, 0666);
> >   if (fd2 == MACH_PORT_NULL)
> >     error (1, errno, "file_name_lookup");
> > #endif
> 
> I hadn't realized in your previous code: contrary to what the variable
> name suggests, this code is not actually creating an fd, so your fork
> hook won't find an fd to unlock.  I however don't know what makes you
> say that the hook is not triggered, so I can't really deduct anything.

Well the basic problem is of course to detect processes generated by
fork(2). Seems like iterating over open FDs is not sufficient. 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*?




reply via email to

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