Sponsored Content
Top Forums UNIX for Advanced & Expert Users How to prevent gdb to send Interrupt signals to child processes Post 302281626 by otheus on Thursday 29th of January 2009 07:47:29 AM
Old 01-29-2009
The children should terminate when the parent does. If the children die, the parent normally gets notified with a SIGCHLD signal. However, by default, this signal is ignored.It could be in your code you are trying to handle it or have reset it to terminate your own process. Look for SIGCHLD in your code.

You should also tell your own process to handle or ignore SIGINT so that your process doesn't get killed when CTRL-C is hit. Try adding this early in the initialization of your program:
Code:
signal(SIG_IGN, SIGINT);

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

what are parent and child processes all about?

I don't follow what these are... this is what my text says... "When a process is started, a duplicate of that process is created. This new process is called the child and the process that created it is called the parent. The child process then replaces the copy for the code the parent... (1 Reply)
Discussion started by: xyyz
1 Replies

2. Programming

Controlling child processes

Hello all, I am trying to create n child processes and control them from a parent process; say make child 3 print its pid and then child 5 do the same and some other stuff. Is there a way to accomplishing this after all the child processes are created via a call to fork(). Thank you, FG (23 Replies)
Discussion started by: forumGuy
23 Replies

3. UNIX for Advanced & Expert Users

gdb to child process

Hi, I want to debug a child process which is forked from other process. Whenever I try to attach the pid of child process to gbd, the process gets killed and the parent process starts a new child process. any idea what could be the reason. In general how can i debug a child process... (4 Replies)
Discussion started by: shriashishpatil
4 Replies

4. Shell Programming and Scripting

Parent/Child Processes

Hello. I have a global function name func1() that I am sourcing in from script A. I call the function from script B. Is there a way to find out which script called func1() dynamically so that the func1() can report it in the event there are errors? Thanks (2 Replies)
Discussion started by: yoi2hot4ya
2 Replies

5. Programming

fork() and child processes

Hello, How many child processes are actually created when running this code ? #include <signal.h> #include <stdio.h> int main () { int i ; setpgrp () ; for (i = 0; i < 10; i++) { if (fork () == 0) { if ( i & 1 ) setpgrp () ; printf ("Child id: %2d, group: %2d\n", getpid(),... (0 Replies)
Discussion started by: green_dot
0 Replies

6. Shell Programming and Scripting

fork() and child processes

Hello, How many child processes are actually created when running this code ? #include <signal.h> #include <stdio.h> int main () { int i ; setpgrp () ; for (i = 0; i < 10; i++) { if (fork () == 0) { if ( i & 1 ) setpgrp () ; printf ("Child id: %2d, group: %2d\n",... (1 Reply)
Discussion started by: green_dot
1 Replies

7. UNIX for Advanced & Expert Users

killing all child processes

Hi, Is there a way I can kill all the child processes of a process, given its process id. Many thanks in advance. J. (1 Reply)
Discussion started by: superuser84
1 Replies

8. Programming

How to block or ignore signals from certain processes?

We know that a process can block certain signals by call sigprocmask(), but sometimes we may want to block signals from certain processes for safety concerning. For example, a system may have a process management daemon, and it will response to certain signals from certain processes managed by... (4 Replies)
Discussion started by: aaronwong
4 Replies

9. Programming

sending signals between two processes

Hello, I have two programs: server.c and client.c I need to send signal from client to server. As far as I know I need to use kill() function. To use kill() function I have to know the pid the second process. How can I send pid from process to process(both are written in separate files). ... (3 Replies)
Discussion started by: fasolens
3 Replies

10. Shell Programming and Scripting

Get all child processes of a process

is there a universal way of getting the children of a particular process? i'm looking for a solution that works across different OSes...linux, aix, sunos, hpux. i did a search online and i kept finding answers that were specific to Linux..i.e. pstree. i want to be able to specify a process... (2 Replies)
Discussion started by: SkySmart
2 Replies
signal(3C)						   Standard C Library Functions 						signal(3C)

NAME
signal, sigset, sighold, sigrelse, sigignore, sigpause - simplified signal management for application processes SYNOPSIS
#include <signal.h> void (*signal(int sig, void (*disp)(int)))(int); void (*sigset(int sig, void (*disp)(int)))(int); int sighold(int sig); int sigrelse(int sig); int sigignore(int sig); int sigpause(int sig); DESCRIPTION
These functions provide simplified signal management for application processes. See signal.h(3HEAD) for an explanation of general signal concepts. The signal() and sigset() functions modify signal dispositions. The sig argument specifies the signal, which may be any signal except SIGKILL and SIGSTOP. The disp argument specifies the signal's disposition, which may be SIG_DFL, SIG_IGN, or the address of a signal han- dler. If signal() is used, disp is the address of a signal handler, and sig is not SIGILL, SIGTRAP, or SIGPWR, the system first sets the signal's disposition to SIG_DFL before executing the signal handler. If sigset() is used and disp is the address of a signal handler, the system adds sig to the calling process's signal mask before executing the signal handler; when the signal handler returns, the system restores the calling process's signal mask to its state prior to the delivery of the signal. In addition, if sigset() is used and disp is equal to SIG_HOLD, sig is added to the calling process's signal mask and the signal's disposition remains unchanged. The sighold() function adds sig to the calling process's signal mask. The sigrelse() function removes sig from the calling process's signal mask. The sigignore() function sets the disposition of sig to SIG_IGN. The sigpause() function removes sig from the calling process's signal mask and suspends the calling process until a signal is received. RETURN VALUES
Upon successful completion, signal() returns the signal's previous disposition. Otherwise, it returns SIG_ERR and sets errno to indicate the error. Upon successful completion, sigset() returns SIG_HOLD if the signal had been blocked or the signal's previous disposition if it had not been blocked. Otherwise, it returns SIG_ERR and sets errno to indicate the error. Upon successful completion, sighold(), sigrelse(), sigignore(), and sigpause(), return 0. Otherwise, they return -1 and set errno to indicate the error. ERRORS
These functions fail if: EINTR A signal was caught during the execution sigpause(). EINVAL The value of the sig argument is not a valid signal or is equal to SIGKILL or SIGSTOP. USAGE
The sighold() function used in conjunction with sigrelse() or sigpause() may be used to establish critical regions of code that require the delivery of a signal to be temporarily deferred. If signal() or sigset() is used to set SIGCHLD's disposition to a signal handler, SIGCHLD will not be sent when the calling process's children are stopped or continued. If any of the above functions are used to set SIGCHLD's disposition to SIG_IGN, the calling process's child processes will not create zom- bie processes when they terminate (see exit(2)). If the calling process subsequently waits for its children, it blocks until all of its children terminate; it then returns -1 with errno set to ECHILD (see wait(3C) and waitid(2)). The system guarantees that if more than one instance of the same signal is generated to a process, at least one signal will be received. It does not guarantee the reception of every generated signal. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
exit(2), kill(2), pause(2), sigaction(2), sigsend(2), waitid(2), signal.h(3HEAD), wait(3C), attributes(5), standards(5) SunOS 5.11 6 Sep 2007 signal(3C)
All times are GMT -4. The time now is 09:24 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy