Solved

Unix process termination

Posted on 2002-04-10
7
532 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
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…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

617 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