Is there a difference between having the following code at the begining of program ‘progX’
if(daemon(0, 0) == -1)
{
printf("daemon error: %s", strerror(errno));
}
or running ‘progX’ via the command: progX & 2>/dev/null 1>/dev/null 0>/dev/null
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
daemon()does several things:initby forking and then exiting the parent. Look in thepslist and you’ll see that daemons are owned by PID 1.setsid()././dev/null.Your redirections handle the last action but not the rest.