![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| script to monitor process running on server and posting a mail if any process is dead | pradeepmacha | Shell Programming and Scripting | 12 | 10-17-2008 12:08 AM |
| daemon process | suresh_rupineni | Linux | 1 | 08-20-2006 11:14 PM |
| zombie daemon process!! | rish2005 | UNIX for Advanced & Expert Users | 1 | 11-25-2005 06:59 AM |
| Should a UNIX daemon process close open fds? | kunalashar | UNIX for Dummies Questions & Answers | 1 | 10-24-2002 06:10 AM |
| what is a daemon process | Kanu77 | High Level Programming | 6 | 03-08-2002 07:47 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Hi,
I have to write a daemon process, which performs certain operations in the background. Now since it performs operations in the background, it should not display anything to the standard output. The problem is that it still displays, text on standard output. Can anyone tell me (it is urgent) how to avoid this. I have written the following function to initialize the daemon code ... int daemon_init() { int pid, fd; if (getppid() == 1) { goto out; } #ifdef SIGTTOU signal(SIGTTOU, SIG_IGN); #endif #ifdef SIGTTIN signal(SIGTTIN, SIG_IGN); #endif #ifdef SIGTSTP signal(SIGTSTP, SIG_IGN); #endif pid = fork(); if (pid < 0) { return -1; } else if (pid > 0) { /* In parent exit leaving the child to work */ exit(0); } if (setpgrp() == -1) { return -1; } signal(SIGHUP, SIG_IGN); pid = fork(); if (pid < 0) { return -1; } else if (pid > 0) { /* first child exits */ exit(0); } out: /*for (fd = 3; fd < NOFILE; fd++) close(fd);*/ /* In child detach from the parents session */ /*setsid();*/ chdir("/"); umask(0); return 0; } |
| Forum Sponsor | ||
|
|
|
#3
|
|||
|
|||
|
If the daemon process is still sending text to the o/p , i think u can direct the o/p of the daemon
process to /dev/null and i think it shouldn't be a problem |
|||
| Google The UNIX and Linux Forums |