From: Denys Vlasenko
> Sent: 01 March 2022 21:57
>
> On Tue, Mar 1, 2022 at 5:39 PM Denys Vlasenko <[email protected]>
> wrote:
> > Meanwhile: what "timeout" is doing is it tries to get out
> > of the way of the PROG to be launched so that timeout's parent
> > sees PROG (not timeout) as a child. E.g. it can send signals
> > to it, get waitpid notifications if PROG has been stopped
> > with a signal, and such.
> >
> > And PROG also has no spurious "timeout" child.
> > "timeout" exists as an orphaned granchild.
> >
> > Let's go with a solution with fd opened to /proc/PID?
>
> This little test:
>
> int fd = open("/proc/self", O_RDONLY);
> int parent = getpid();
> int pid = fork();
> if (pid) { //parent
> sleep(1);
> exit(0);
> }
> sleep(2);
> printf("openat:%d\n", openat(fd, ".", O_RDONLY));
> while (openat(fd, ".", O_RDONLY) == -1)
> continue;
>
> and a separate "spawn 40k 'sleep 0.03'" loop
> seems to indicate that openat(fd, ".") on the exited
> /proc/PID fails, and continues to fail
> even if another process with this PID exists
> again (pid was reused).
Which kernel?
That may not fail on pre-pidfd kernels.
There were some discussions on the linux kernel mailing list
that I half followed.
But it is probably a lot better that anything else at least
for the current kernels that people are probably going to use.
(Apart from those of us who have to build release binaries
on old systems in order that customers can run them on the
old distros they like to use....)
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT,
UK
Registration No: 1397386 (Wales)
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox