Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

If I run a program with an infinite loop with nohup, will the program run indefinitely (until the machine is reset or until I manually terminate it)?

share|improve this question
add comment

2 Answers

up vote 13 down vote accepted

Nohup sets the default behavior of the HANGUP signal, which might get overriden by the application. Other signals from other processes with permission (root or same user) or bad behavior (seg faults, bus errors) can also cause program termination. Resource limitations (ulimit) can also end the program.

Barring these, your infinite loop might well run a very long time.

share|improve this answer
add comment

Following are the two important line from nohup's source code.

(void)signal(SIGHUP, SIG_IGN); // Ignore SIGHUP

execvp(*argv, argv); // Run the command.

So until your application calls something like

signal (SIGHUP, SIG_DFL); //OR some custom signal handler

In the normal circumstances it will continue to run until you restart machine or kill it yourself.
It might also be terminated in the cases pointed by kmarsh.

share|improve this answer
add comment

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.