Quote:
Originally Posted by matrixmadhan
i have some kind of clarification here..
can all the process without a controlling terminal be termed as a daemon ? ....
isnt that a daemon should necessarily be a session leader ... >>>
Good heavens, no!
A program like "cron" needs to be able to daemonize itself. That is, I should be able to start cron from a tty. If I do that, cron will have a controlling terminal when it first starts to run. To lose that controlling terminal (on a Posix compliant system), a sequence of steps is needed which does indeed include becoming a session leader. I believe that this may be what you are thinking of.
However, this is just a transitory state. A correctly written modern daemon will then fork(). The parent (a session leader) will exit. The child (not a session leader) will then strive to run forever. Since it is not a session leader, it can open a tty device without acquiring it as a controlling terminal. In the old days, a daemon would need to fork() every time it wanted to write on /dev/console. The child would open /dev/console, write(), then exit().
And that brings up an interesting point. The session concept arose during the 90's. Until there were sessions, a process could not be a session leader. But early versions of unix, although they lacked sessions, did indeed have daemons. "No controlling terminal" is the definition of daemon that I learned in the early 80's. I have never seen anything to challenge that. But I don't think that "daemon" has its definition controlled by a standards body or anything like that.
1.7 How do I get my program to act like a daemon?