Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
    
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 Answer 1

up vote 1 down vote accepted

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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