Thanks to both Ole and Ronny for enlightening me. :) -- Joshua Butikofer Cluster Resources, Inc.
[EMAIL PROTECTED] Voice: (801) 717-3707 Fax: (801) 717-3738 -------------------------- Ole Holm Nielsen wrote: > Ronny T. Lampert wrote: >>> I'm not sure I understand what you mean by "daemon should duplicate >>> all standard descriptors to >>> /dev/null." Perhaps you can help me in my ignorance. >> >> Ah, yes. Usually, fully background daemons close 0, 1 and 2 (stdin, >> out and err) and dup() them to /dev/null, and also do a setsid(). >> >> This prevents accidentially opened ttys (and sessions) to be held open >> or msgs (e.g. perror()) going somewhere where they possibly shouldn't. >> One also could dup() them to a file, so all output goes there in case >> some library functions really wants to use stdout or -err. >> >> I think closing stdin is quite crucial to correct operation, else the >> daemon could accidentially get blocked. > > I've also noticed that if I restart the maui daemon, my interactive > SSH-login shell to the central server refuses to terminate. I have > to kill the shell from adifferent window. Fortunately, the maui > daemon has always survived this harsh treatment of its open file > descriptors. > > I have a (possibly naive) snippet of code from another type of > daemon process where the files are properly closed: > > /* Become a daemon */ > pid = fork(); > if (pid > 0) { /* Parent */ > /* Close parent's streams */ > fclose (stdin); > fclose (stdout); > fclose (stderr); > return(0); > } else if (pid < 0) { /* Error */ > printf("%s: Could not fork child process\n", argv[0]); > return(-1); > } > > The Maui code in src/server/OServer.c doesn't close file descriptors, > which IMHO it ought to do. Ronny has even more detailed suggestions > above which I don't claim to understand fully. > > Best regards, > Ole Holm Nielsen > Technical University of Denmark _______________________________________________ mauiusers mailing list mauiusers@supercluster.org http://www.supercluster.org/mailman/listinfo/mauiusers