init and process control


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers init and process control
# 1  
Old 12-14-2006
init and process control

I'm trying to wrap my head around process control in Unix... particularly init and how it fits in to the equation. Init is responsible for creating sessions by spawning instances of getty which calls login effectively creating sessions right? Why then can init belong to a session? If you ps jx 1, you will see init belongs to SID 1. Is SID 1 a pseudo session or just a bogus number added as a formality to the output of ps? I notice that a lot of other low level user processes belong to this special session. Could someone explain to me a little more about it? I've been googling all over the place today for a clearer understanding.

Thanks.

Dex
# 2  
Old 12-14-2006
init, the instance with a pid of 1, is not created via a fork(). The kernel handcrafts it and can do whatever it wants. That said, I don't really see anything terribly odd about sid 1 and I don't understand your confusion.

init was always created with a ppid of 0, even before there was a process 0. Today process 0 tends to be its own parent. There is a lot of weird stuff about non-forked processes. Why did you zero in on sid?

In any event sid 1 is a real sid, but it's not obvious what else it might be. What do you mean by psuedo-session?
# 3  
Old 12-14-2006
Ok... thanks Perderabo. That helps. I was thinking of sessions as something created via the login process and didn't understand how login could create the session that init was in. It sounds like sessions are not as tightly coupled with login as I initially thought. When you say “there are a lot of weird stuff about non-forked processes” do you mean that others exist or that there are other weird things about init? We are talking about process control in a systems programming course I'm taking, so that is why I zeroed in on SID. I figured the value aught to be -1 like TGPID.
# 4  
Old 12-15-2006
Stuff like this depends on the version of unix. But most have a process 0. Read the man page for setsid(). Also read this: http://www.erlenstar.demon.co.uk/unix/faq_2.html#SEC16
and notice that correctly written daemons put themselves into a separate session.
# 5  
Old 12-15-2006
Great link. Steps one and two of creating a daemon finely filled in the gaps and clarified it for me. Thanks again!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

forking a child process and kill its parent to show that child process has init() as its parent

Hi everyone i am very new to linux , working on bash shell. I am trying to solve the given problem 1. Create a process and then create children using fork 2. Check the Status of the application for successful running. 3. Kill all the process(threads) except parent and first child... (2 Replies)
Discussion started by: vizz_k
2 Replies

2. Red Hat

init-script failing because of /etc/rc.d/init.d/functions

I encountered a problem on one of our database servers. OS: CentOS 5.5 final Kernel: 2.6.18-238.5.1.el5.028stab085.2 (OpenVZ kernel) We wrote some DB-Start/Stop-scripts ("/db2/admin/scripts_dba/start_services.ksh" and ".../stop_services.ksh") to start the database instances. (Database... (1 Reply)
Discussion started by: bakunin
1 Replies

3. Shell Programming and Scripting

control timeout of sqlplus process

Hi, I'm using simple sqlplus to test DB availability. When DB is going down, sqlplus command is hang for a few minutes I want to implement the following: 1. execute sqlplus 2. if after 20 sec I dont get a response, kill the process and exit with error. 3. if I get immediate response... (2 Replies)
Discussion started by: gdan2000
2 Replies

4. UNIX for Dummies Questions & Answers

init adopts zombie process?

Hi I tried to create a zombie process with the following program: int main(void) { pid_t pid; int status; if ((pid = fork()) < 0) perror("fork error"); else if (pid == 0){ /* child process*/ exit(0); } ... (3 Replies)
Discussion started by: password636
3 Replies

5. Shell Programming and Scripting

job/process scheduling or control

Hi forum, I have a problem concerning job or process scheduling and control. I have to run 24 jobs (could be more sometimes less) of the same programme with different parameters. The machine this code is running on is an 8-core machine, so I was thinking that running all the processes at once... (0 Replies)
Discussion started by: deiphon
0 Replies

6. UNIX for Advanced & Expert Users

Control process from different terminal (over SSH)

I pressed CTRL Z and suspended the job. then I pressed bg, The process re-started to throw output on the terminal and its not allowing me to access the prompt. its not even accepting CTRL Z. The process has been running for about 2 hours now and I want to suspend it by opening another terminal.... (3 Replies)
Discussion started by: rakeshou
3 Replies

7. Shell Programming and Scripting

2 Questions about my process control script

Hi all, My tiny mind is struggling with the following script that shuts down Tomcat on Sol. 8 and kills any defunct processes Tomcat might leave behind (as it so often does). I realize that fixing Tomcat would be best, but this is a band-aid so I won't have to do as much off-hours support of... (3 Replies)
Discussion started by: dkaplowitz
3 Replies

8. UNIX for Advanced & Expert Users

control the process

I found that in my system , there are some strange process , it will make the system crash so I would like to control the system no such process is running , this is if the system process that its process name is "ora" AND its ppid is not "2" , then it will crash the system, can suggest how to... (2 Replies)
Discussion started by: ust
2 Replies

9. Programming

Reading a process control block

Hello, I want to know what call to use to read the details of a process control block in solaris ?:) (2 Replies)
Discussion started by: hmurali
2 Replies

10. Filesystems, Disks and Memory

unix process control

can anyone send me enything about "unix process control " nicko@freemail.com.mk (2 Replies)
Discussion started by: nicko
2 Replies
Login or Register to Ask a Question