Exit() system call verses process signals

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Exit() system call verses process signals
# 1  
Old 01-07-2017
Exit() system call verses process signals

Hello and thanks in advance for any help anyone can offer me

I've been reading up on process signal calls (sighup, sigint, sigkill & sigterm) and I understand they all have different methods of terminating a running process. From what I've also read is a exit() actually terminates a process.

I'm curious to understand the process Linux goes about to terminating a process with exit() after a process signal has been issued. I've searched google but haven't seen anything that steps thru this. Could someone give me a quick & dirty explanation of this?

Much thanks!
# 2  
Old 01-08-2017
The exit() is called by the process to terminate itself.
The (kill-)signals are sent to a process. A proccess, when it receives a signal, as a default action (defined in libc) terminates (via exit()).
A process can define signal handlers that are invoked when a signal arrives and typically do some cleanup and then often exit().
The signal 9 (SIGKILL) is special: it is not sent to the process but to the kernel; the kernel clears the process memory.
# 3  
Old 01-09-2017
Or to add a little to MadeInGermany's answer -

SIGKILL prevents normal process rundown. It can leave open files in bad condition, for example. You should use it only a last resort when you cannot force a process to exit. In some version of UNIX there are processes you cannot kill.

ps -u in Linux shows a column "stat".
Quote:
Status codes for Linux as of 2.6 kernel AFAIK.
Stat Meaning
D Uninterruptible sleep (usually IO)
R Running or runnable (on run queue)
S Interruptible sleep (waiting for an event to complete)
T Stopped, either by a job control signal or because it is being traced.
W paging (not valid since the 2.6.xx kernel)
X dead (should never be seen)
Z Defunct (“zombie”) process, terminated but not reaped by its parent
D means the process cannot be killed while in the "D" status.
"Z" gets people upset completely. It means all of the processes' resources except the information kept in the kernel process header are gone. It will NOT do anything except reduce the number of total process slots by one. So if your system is configured for 65535 processes maximum, for example, then you just lost one until the "Z" process goes away. This is the result of poor programming practices - exiting and not waiting for child processes to terminate and be 'reaped'.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Check file if not found send mail if exit call second script

I need to check my script and change to working mode. currently it was not sending the mail and exit without calling the second script. I need to check the file is present ="/home/Rvtools/test.csv" if this file not found after the time retry send mail file not found If the file exit run the... (2 Replies)
Discussion started by: ranjancom2000
2 Replies

2. UNIX for Advanced & Expert Users

Handling Signals in System Calls

What will happen if signal comes while a system call is being executed? How it will be handled? (1 Reply)
Discussion started by: rupeshkp728
1 Replies

3. Shell Programming and Scripting

Check the exit status in a pipe call

Guys, I have a problem :confused: and I need some help: I've to process many huge zip files. I'd code an application that receive the data from a pipe, so I can simple unzip the data and send it (via pipe) to my app. Something like that: gzip -dc <file> | app The problem is: How can I... (7 Replies)
Discussion started by: Rkolbe
7 Replies

4. Shell Programming and Scripting

call b.sh from a.sh, and continue to a.sh after use exit 0 from b.sh

Hi, I have two sh file. a.sh and b.sh b.sh is command and used by other sh's. I want to add below line to b.sh. When it is done with b.sh I want to continue to process a.sh. But when I use exit 0 in b.sh it is exit from b.sh and a.sh How can I make it to continue to process? a.sh ... (2 Replies)
Discussion started by: ctuncer
2 Replies

5. Shell Programming and Scripting

process and exit to new page

File1 --> into shell file for processing --> file2 I have finished the work on my shell processing script, but I need to call this from a form -->cgi-bin, have the form wait/process bar while processing occurs (5-10 seconds) and then have the shell exit gracefully while transferring to the new... (1 Reply)
Discussion started by: dba_frog
1 Replies

6. UNIX for Advanced & Expert Users

Ignored signals & blocking system calls

If I explicity ignore a signal (for example, SIGALRM), and this signal is generated during a blocking system call (for example, a recvfrom() ), what happens to the system call? Does it abort, or does it remain blocked until its end? (2 Replies)
Discussion started by: hurricane
2 Replies

7. UNIX for Advanced & Expert Users

Process signals as administration

Too generic to post elsewhere, too advanced for the newbie forums. There are some applications within the unix/linux milieu that understand signals such as SIGHUP, etc as instructions to perform administrative tasks (clearing information out of this, disconnect users, etc.) I was just wondering if... (2 Replies)
Discussion started by: thmnetwork
2 Replies

8. UNIX for Dummies Questions & Answers

UNIX System Call for creating process

Hell Sir, This is chanikya Is there any System call which behaves just like fork but i dont want to return back two times to the calling func. In the following ex iam creating a child process in the called func but the ex prints two times IN MAIN. ex :- calling() { fork(); } ... (2 Replies)
Discussion started by: chanikya
2 Replies

9. UNIX for Advanced & Expert Users

how to differentiate system call from library call

Hi, Ho do I differentiate system call from library call? for example if I am using chmod , how do I find out if it is a system call or library call? Thanks Muru (2 Replies)
Discussion started by: muru
2 Replies

10. Programming

Problem with signals - 3 process communication

Hello, I would like to ask you for a little help with program I'm working on. I have problems with signals and synchronizing processes (I'm quite new to this part of programming). Process "parent" creates new child process "child1" and this process creates new child process "child2". The... (2 Replies)
Discussion started by: Nightwright
2 Replies
Login or Register to Ask a Question