Solved

Unix process termination

Posted on 2002-04-10
7
527 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

856 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