From nobody Sun Mar 17 19:21:30 2024 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TySXB65HVz5Dxd7 for ; Sun, 17 Mar 2024 19:21:30 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TySXB4ZZqz4Qp7 for ; Sun, 17 Mar 2024 19:21:30 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1710703290; a=rsa-sha256; cv=none; b=uIqxoDApUyQBrgXiJiN9xdv4gEUyRbtnHajZ2cEbO6wUMhe6DoTm9yFrVMgMAcDar0SzAP TSYu2bP0ZoY1F/GOGvIf6/rGHod5jT6V7wMkqTLDrLSYxLcxXizremaMGiMSm1yhTBwpZk x3CW+Nz6tfwxda+N86Bw1lRc8tN6GMvWZkcceQQJhei/qAVtvhmffIAgGWv5VoRlQalY8K UrrUYUkZ6gILCI9Yw1gTW5sE6UxPPpdN1mqsBdj1mhuyxqdwgXfsPIfzqI1Hn/bD711C6l bk8RiRoqAnJdKunyBEc+wb52Wx0JJQ/lpqR1QgP7cYGf9gPwnvVpTwb31LHnFg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1710703290; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Ts55dU0bmB4AeEmmX+FxXx3K6+Bjp0sDTnk7n23SvGs=; b=jI0UNDDX785zegyFPkoa6EChdSK+4pcdTi65pv6Wo/t9SYQEfJviYjAvHuOtwv16mhXxQi DIRFv0pVohwmnQ1Z+4XAmW42G0EdO6kmFYXeG05g6qDAxVRp4nGp7PUW4aeJfUjBA+c7Ea fwGPGoSHeY/Lhc6JKk/RuGxkWJjF6VplUI4teEwO0VYoOS62hO/HJ7TgWD2SxvHHiljU92 qe+R9secQ6dQWjtO1PJa8JD6NLGwND5w6wmRle9tI9aCnTYXONb/VS/aW+gf3uMWq9RuxI WBZ/1KuUfIZN8dj9lmuWrkcjv5Fhgq1hJVydiINJyU24ABzl0JmKDQWdo9imLw== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TySXB4CFwzrWH for ; Sun, 17 Mar 2024 19:21:30 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 42HJLUUq042864 for ; Sun, 17 Mar 2024 19:21:30 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 42HJLUpv042835 for bugs@FreeBSD.org; Sun, 17 Mar 2024 19:21:30 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 277764] daemon(8): high CPU usage after stopping and continuing child process Date: Sun, 17 Mar 2024 19:21:30 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: 5mxnbm6q5@mozmail.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 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.=