Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Unix process termination

Posted on 2002-04-10
7
Medium Priority
?
544 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 800 total points
ID: 6936611
There is no difference from that standpoint.  All cleanup will occur either way.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 21

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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
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.
Suggested Courses
Course of the Month9 days, 14 hours left to enroll

926 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