ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
In the below code , when system function get executed (in LINUX and compiled with g++) , it will send the SIGCHLD signal to process (from which it is called) which doesn't happen in solaris code i mean if i run the same code in solaris, system function doesn't send any signal to process from which it is called.As a result of which my process in Linux got hanged.
my question is :
1) why the process get hanged in the above case
2) why in solaris , system function doesnt send any signal
and my last question which is related to my real application is :
Actually , in my real application , some other process sending the SIGKILL signal to my process and in signal handler i am killing the one process using system function as a result it got hanged(which is similar to the above scenario). Is there any way to overcome this.
No process is able to catch a SIGKILL (9) signal. Can you please elaborate as to what the issue is with your real application?
As for your sample application, why are you calling system() from within the signal handler?? Duh... that is going to generate another SIGCHLD, and... in other words, the exit() function call in the signal handler will never be reached.
P.S. I should have added that a system() call will fork a child-process; hence when that child exits, a SIGCHLD signal is issued.
Last edited by dwhitney67; 08-17-2012 at 08:15 AM.
man 7 signal
The entries in the "Action" column of the table specify the default action for the signal, as follows:
Term Default action is to terminate the process.
Ign Default action is to ignore the signal.
Core Default action is to terminate the process and dump core.
Stop Default action is to stop the process.
First the signals described in the original POSIX.1 standard.
Signal Value Action Comment
-------------------------------------------------------------------------
<...unrelated entries trimmed...>
SIGCHLD 20,17,18 Ign Child stopped or terminated
This is described as the POSIX-compliant behavior.
So it seems that for some reason, your program's default signal action has been modified. Since this property is inherited from the parent process, perhaps that is one avenue to explore. Other wise, perhaps the change is an inadvertent side effect of some API that your application is bound to.
It is possible that Solaris does not conform to POSIX standards for this.
The recursive signal handling in your example may be masking or exacerbating the real root of the matter.
Having a look with strace it looks like system() includes a waitpid(). As the first waitpid() is never closed, the second waitpid() in the signal handler can’t be created. At this point it hangs.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.