Home » Questions » Computers [ Ask a new question ]

Why gksudo does not exit after it started background process?

Why gksudo does not exit after it started background process?

I'm trying to run conky with gksudo (to get top amongst all process, not just mine) but I have really strange issue. Despite the fact that conky forks itself and exit immediately, gksudo won't exit at the same time. If I close it with Ctrl+C conky continue to run which proves that it had forked successfully. How can I make gksudo see that process it started has ended and give me my shell back?

Asked by: Guest | Views: 35
Total answers/comments: 1
Guest [Entry]

"When conky forks itself and exits, the parent process that gksudo created will continue to hang around as a zombie process.

On Unix and Unix-like computer operating systems, a zombie process or defunct process is a process that has completed execution but still has an entry in the process table. This entry is still needed to allow the process that started the (now zombie) process to read its exit status. The term zombie process derives from the common definition of zombie—an undead person. In the term's colorful metaphor, the child process has died but has not yet been reaped.

As long as this process is present, gksudo will continue to run. From its man page:

Upon successful execution of a program, the return value from sudo will simply be the
return value of the program that was executed.

If you're running this interactively, run it in the background as suggested, and for non-interactive use, give root permission to conky or the wrapper script via the /etc/sudoers file.

Edit: Using the gvim example in the other answer:

$ #gksudo running
$ ps -ef | grep gvim
171:nagul 22876 9378 0 12:18 pts/1 00:00:00 gksudo gvim
172:root 22877 22876 0 12:18 ? 00:00:00 [gvim] <defunct>
176:root 22892 1 0 12:18 ? 00:00:00 gvim

$ #gksudo killed via Ctrl-C
$ ps -ef | grep gvim
174:root 22892 1 0 12:18 ? 00:00:00 gvim"