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?

1
  • 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
    Commented Dec 30, 2011 at 14:12

1 Answer 1

1

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

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .