Solved

Unix process termination

Posted on 2002-04-10
7
517 Views
Last Modified: 2010-05-18
Before asking the question I am describing the scenario
I have a child process that I have created from the parent by using fork. Now I have registered a signal handler for my user defined signal in the child process. The child process after doing something is waiting in infinite loop. After something I fire the signal from the parent process and in the signalk handler I have a call to exit to terminate the child process. It works fine. But consider the following scenario also.
   The same child process is waiting for some input from standard input device(keyboard) without waiting in infinite loop. And sometime I supplied the input and it will encouter the terminating brace and the child process will terminate.
  Now my question is Is there any difference between these two kind of termination.
  If u need any clarification regarding this feel free to ask me.
  Waiting for help or any link where I can have some discussion on this topic,
 Thanking u in advance  
                    Souvik
0
Comment
Question by:souvik_mss
7 Comments
 
LVL 40

Expert Comment

by:jlevie
ID: 6935629
Not really as fas as the child is concerned. In both cases the child will have exited, presumably in an orderly manner. However, it migh make a difference to the parent. In the case of sending a signal from the parent, the parent has reason to believe that the child will exit. On the other hand if the child exits on it's own the parent process won't necessarily know that.
0
 

Author Comment

by:souvik_mss
ID: 6936111
I want to know about the system cleanup and the open file descriptor of the child when terminated by signal. I am not interested about parent process and even if any one get interested, she/he can call wait on its child's pid. My point of interest is that when the child process terminates by exit call inside signal handler then will the destructor of the objects created will be called or suppose the socket(file descriptor) by which that the process was communicating with some other process will get closed. My question is will the memory dynamically locked will be freed.
0
 
LVL 14

Accepted Solution

by:
chris_calabrese earned 200 total points
ID: 6936611
There is no difference from that standpoint.  All cleanup will occur either way.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 40

Expert Comment

by:jlevie
ID: 6936724
As ususal chris is quite correct.
0
 
LVL 2

Expert Comment

by:JYoungman
ID: 7150129
Cleanup is identical in both cases, *unless* you have code registered with atexit() which cleans up SYSV IPC resources (the Unix kernel always cleans up everything except SYSV IPC resources for you).  

If you opened a scratch file with something like mktemp(), of course you would need to clean them up yourself (and hence calling exit() would allow an atexit()-registered handler to do that while a fatal signal would not).   But tmpfile() would have been better in any case - no file is left lying around because it's deleted before the tmpfile() function returns.
0
 
LVL 20

Expert Comment

by:tfewster
ID: 7833696
No comment has been added lately, so it's time to clean up this Topic Area.
I will leave a recommendation for this question in the Cleanup topic area as follows:

- Answered by chris_calabrese

Please leave any comments here within the next 7 days

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

tfewster (I don't work here, I'm just an Expert :-)
0
 

Expert Comment

by:modulo
ID: 7909028
Finalized as proposed

modulo

Community Support Moderator
Experts Exchange
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now