Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:

import subprocess["/bin/bash", "-c", "exec /sbin/init 2"])"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;; exec /sbin/init 2; but it isn't very nice workaround – user39684 Dec 30 '11 at 14:12
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


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.