You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our Linux is systemd-based. What happens in the end when /sbin/reboot is called, is that the reboot.target is activated.
This leads to SIGTERM (15) being sent to all user context processes.
Depending on if the reboot finishes before receiving SIGTERM itself or after it exits with code 0 or with code 15.
This looks like a race-condition that is not appropriately handled in the adu-shell child process that issues the reboot due to adu-shell not registering and handling SIGTERM properly.
The agent execs a seteuid'ed adu-shell child process so that it can issue a shutdown as root user. The adu-shell child process is receiving SIGTERM signal after it had invoked /sbin/reboot and does not have a registered signal handler for SIGTERM so its process is terminated.
Therefore, in the agent parent process, waitpid() leads to a wait status where WIFSIGNALED(wstatus) being true here:
Log_Info("Child process terminated, signal %d", childExitStatus);
I think the following is needed in a fix:
adu-shell must register a handler function for SIGTERM
The SIGTERM signal handler should ignore the signal if reboot cmdline arg has been parsed as the action
After waitpid() leads to child wait status of 0 success, the parent AducIotAgent process should perhaps proactively call ADUC_ShutdownService_RequestShutdown() to set s_isShuttingDown = true before waiting for SIGTERM to come and doing so here:
Ideally, in adu-shell, it can also be switched to using int syscall(SYS_reboot, int magic, int magic2, int op, void *arg); instead of invoking system("/sbin/reboot"), but that involves using the magic number arguments that are Linus Torvalds' birthday and his 3 daughters' birthdays in hex.
Expected Behavior
Reboot without error in the log.
Current Behavior
Despite the reboot working an error is logged.
Steps to Reproduce
Device Information
*DU Agent Version: 1.1
Logs
Additional Information
Our Linux is systemd-based. What happens in the end when /sbin/reboot is called, is that the reboot.target is activated.
This leads to SIGTERM (15) being sent to all user context processes.
Depending on if the reboot finishes before receiving SIGTERM itself or after it exits with code 0 or with code 15.
See also
https://systemd-devel.freedesktop.narkive.com/JafJo2Lj/systemctl-reboot-get-terminated-by-signal-15
The text was updated successfully, but these errors were encountered: