[Bug 277764] daemon(8): high CPU usage after stopping and continuing child process
- Reply: bugzilla-noreply_a_freebsd.org: "[Bug 277764] daemon(8): high CPU usage after stopping and continuing child process"
- Reply: bugzilla-noreply_a_freebsd.org: "[Bug 277764] daemon(8): high CPU usage after stopping and continuing child process"
- Reply: bugzilla-noreply_a_freebsd.org: "[Bug 277764] daemon(8): high CPU usage after stopping and continuing child process"
- Reply: bugzilla-noreply_a_freebsd.org: "[Bug 277764] daemon(8): high CPU usage after stopping and continuing child process"
- Reply: bugzilla-noreply_a_freebsd.org: "[Bug 277764] daemon(8): high CPU usage after stopping and continuing child process"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 17 Mar 2024 19:21:30 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277764 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 continue 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 SIGCHLD signal and the daemon utility assumes that the child is closing. It then keeps calling waitpid (which returns immediately, returning 0) inside an infinite loop in the daemon_is_child_dead function and this causes the high CPU usage. Also before entering daemon_is_child_dead function, the daemon process is waiting / listening for child output in the listen_child function. That's why 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 output 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? -- You are receiving this mail because: You are the assignee for the bug.