In a bash shell, to make nohup mycommand & an orphan process, I close the bash shell after running the command. Is it possible to do without terminating the parent shell? I would like to know if there are some shell commands similar to system calls fork() and exit() for daemonizing a process.

1 Answer 1


To create an orphan process, the parent must die. If you don't want your shell to die, then the shell must not be the parent of the orphan. The simplest way to do that is to make the shell fork a child process which in turn forks the process that is to become an orphan. This double fork is how daemons are started, as explained in the introduction of the Wikipedia article.

In a shell, you already know how to create a child process: with &. To have a child process which is a fork of the same shell and have it in turn fork a background process, you just need to get the parser to understand you.

{ nohup mycommand & } &
  • Thanks. Are the purposes of double fork in C (in the linked wikipedia article and also in APUE) and in bash (last command in your reply) different? In bash, the purpose is to avoid terminating the original shell, while in C, books.google.com/books?id=kCTMFpEcIOwC&pg=PA466
    – Tim
    Mar 3, 2016 at 8:52

You must log in to answer this question.

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