suspected bug in timeout command

Baruch Siach baruch at tkos.co.il
Wed Feb 9 17:12:43 UTC 2022


Hi Sun,

On Wed, Feb 09 2022, סאן עמר wrote:
> Hi, I'm using busybox for a while now (v1.29.2). and I had an issue with a sigterm send randomly to a process of mine. I debugged it until I found
> it from the timeout process which was assigned before to another process with the same pid. (i'm using a lot of timeouts for a lot of jobs)
> so i looked at the code, "timeout.c" file where it sleep for 1 second in each iteration then check the timeout status. I suspect at this time the
> process timeout monitoring is terminated, but another one with the same pid is already created. which creates unwanted timeout.
>
> There is a comment in there about sleep for "HUGE NUM" will probably result in this issue, but I can't see why it won't occur also in the current
> case.
>
> there is no change of this behaviour in the latest master.
> i would appreciate any help, sun.

Any reference to PID number is inherently racy. There is no solution for
your problem in the traditional POSIX API. Recent Linux kernels provide
the "pidfd" API which is meant to be race free. See for example the
pidfd_open(2) man page, and related system calls.

  https://man7.org/linux/man-pages/man2/pidfd_open.2.html

For some background see LWN coverage of the feature development.

  https://lwn.net/Kernel/Index/#pidfd

baruch

-- 
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -


More information about the busybox mailing list