Re: Development question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


On Sun, 28 Mar 1999, Andrew Apted wrote:
>On linux, getsid(0) will give you the "session id", which I think is the
>process id of the "session leader", which is usually the shell.  

Getsid indeed does return the process identifier of the session leader, but it
would be wrong to assume that that is the shell. Programs that want to put
themselves fully into the background, and not just rely on shell job control to
achieve that goal, typically call setsid in order to completely remove
themselves from the user's login environment. Failure to call setsid means that
they will be killed when the user logs out (unless they have explicitly ignored
the hangup signal).

The best starting point to do what you are trying to do is tcgetpgrp, which
returns the process group identifier of the foreground process group. Without
knowing exactly what you are wanting to do, it's difficult to give explicit
advice beyond this point.

>As far as I know, getsid() is linux specific.  

Setsid is common across all reasonably up-to-date Unix-based systems.

>/proc too.

While some other Unix-based systems support /proc, Linux has by far the best
implementation of this facility which I have seen so far. The others are really
quite primitive.

Dave Mielke           | 856 Grenon Avenue | I believe that the Bible is the
Phone: 1-613-726-0014 | Ottawa, Ontario   | Word of God. Please contact me
EMail: dave@xxxxxxxxx | Canada  K2B 6G3   | if you're concerned about Hell.

[Index of Archives]     [Linux for the Blind]     [Fedora]     [Kernel List]     [Red Hat Install]     [Red Hat Watch List]     [Red Hat Development]     [Gimp]     [Yosemite News]     [Big List of Linux Books]