2

I have entry in grub to start my configuration script written in Python. I would like to give user option to start normal session after the work is done. But I've found that /sbin/init needs to have PID==1, so when I run in Python:

#!/usr/bin/python
...
import subprocess
subprocess.call(["/bin/bash", "-c", "exec /sbin/init 2"])
#subprocess.call("exec /sbin/init 2", shell=True)

-it ends with:

init: Failed to connect to socket /com/ubuntu/upstart: Connection refused

and kernel panic

Is there any solution for this?

  • One possible solution is to run bash script like this: #!/bin/bash; MY_PYTHON_SCRIPT.py; exec /sbin/init 2; but it isn't very nice workaround – user39684 Dec 30 '11 at 14:12
1

You need to exec ( os.execv ) init, not run it as a subprocess. Like this: os.execv('/sbin/init', ['/sbin/init'])

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.