Revert "use systemctl in subprocess"

This reverts commit 82ab54d172.
This commit is contained in:
2026-11-21 09:44:22 +01:00
parent 82ab54d172
commit 04145a7e3c
+8 -11
View File
@@ -9,7 +9,6 @@ import time
import sau import sau
import sau.errors import sau.errors
import sau.helpers
import sau.services import sau.services
import sau.platforms import sau.platforms
@@ -53,16 +52,6 @@ def fork_and_reboot(report_success=True):
else: else:
exit_code=1 exit_code=1
# reboot the systemd way on supported platforms
if os.path.exists('/proc/1/comm'):
with open('/proc/1/comm', 'r') as f:
if f.readline().strip() == 'systemd':
sau.helpers.exec_cmd([ '/usr/bin/systemctl',
'reboot', '--no-block',
'--when=+1m'],
timeout=10)
sys.exit(exit_code)
try: try:
pid = os.fork() pid = os.fork()
if pid != 0: if pid != 0:
@@ -83,6 +72,14 @@ def fork_and_reboot(report_success=True):
log.error("Fork #2 failed when going for reboot: {}".format(err)) log.error("Fork #2 failed when going for reboot: {}".format(err))
sys.exit(1) sys.exit(1)
# reboot the systemd way on supported platforms
if os.path.exists('/proc/1/comm'):
with open('/proc/1/comm', 'r') as f:
if f.readline().strip() == 'systemd':
os.execl('/usr/bin/systemctl', 'systemctl', 'reboot', '--no-block', '--when=+1m')
log.error("Failed to execl?")
sys.exit(1)
sys.stdout.flush() sys.stdout.flush()
sys.stderr.flush() sys.stderr.flush()