Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 17 Mar 2024 19:21:30 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 277764] daemon(8): high CPU usage after stopping and continuing child process
Message-ID:  <bug-277764-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D277764

            Bug ID: 277764
           Summary: daemon(8): high CPU usage after stopping and
                    continuing child process
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: 5mxnbm6q5@mozmail.com

Using daemon utility to execute a program (child) and then sending a stop
signal (ex. SIGSTOP) to the child process and afterwards sending the contin=
ue
signal (SIGCONT) can make the daemon process get stuck at 100% CPU usage.

Full setup:
create a script test.sh containing the following:
```
#!/bin/sh

while true; do echo hello; sleep 1; done
```
execute daemon utility: `daemon -f -p test.pid ./test.sh`
send stop signal: `pkill -STOP -F test.pid`
send continue signal: `pkill -CONT -F test.pid`
wait until test.sh executes `echo hello`
daemon process rises to 100% usage (single core)


As far as i can tell stopping and continuing the child process sends a SIGC=
HLD
signal and the daemon utility assumes that the child is closing. It then ke=
eps
calling waitpid (which returns immediately, returning 0) inside an infinite
loop in the daemon_is_child_dead function and this causes the high CPU usag=
e.
Also before entering daemon_is_child_dead function, the daemon process is
waiting / listening for child output in the listen_child function. That's w=
hy
the above script contains an echo so the daemon will exit that function and=
 go
on to process the SIGCHLD event.

Maybe the fix could be to include WCONTINUED option and setting status outp=
ut
parameter (currently set to NULL) when calling waitpid inside
daemon_is_child_dead and then checking if WIFCONTINUED(status) equals True =
and
in that case returning false?

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-277764-227>