How to foreground a process started by upstart?
Solution 1:
fg
needs a job number, not a PID. There's no job number you can use because any process started by upstart
is not a child of your shell. It won't appear in jobs
output.
Try reptyr
, e.g.:
reptyr 2208
From its man page:
reptyr
is a utility for taking an existing running program and attaching it to a new terminal.
Don't miss this note:
reptyr
depends on theptrace(2)
system call to attach to the remote program. On Ubuntu Maverick and higher, this ability is disabled by default for security reasons. You can enable it temporarily by doingecho 0 > /proc/sys/kernel/yama/ptrace_scope
as root, or permanently by editing the file
/etc/sysctl.d/10-ptrace.conf
, which also contains more information about this setting.
Also note reptyr
only attaches a process to another terminal. This does not mean the process becomes a child of your current shell.
Solution 2:
The fg
command needs the job_id not the process id, you need to run the jobs
command and get the job_id of the process