start by setting up the signal handler before you create the child
And... consider not using functions like printf in a signal handler. See async-signal safe
functions:
Hi everybody,
I'm trying to understand how a parent and child processes interact.
This function( below) basically measures the fork time from the perspective of the parent only.
what i would like to know is how to measure the time from the perspective of parent and child (ie: inserting... (0 Replies)
I want to catch SIGCHLD signal in parent process. I can't use wait() system call to catch SIGCHLD according to project requirment.
Operating system linux 3.1
can any one have a solution for this.
Thanking you,
ranjan (2 Replies)
i am creating children processes using fork system call
every child i create goes to sleep for random time.
when child stops running how can i catch his signal and turminate the child (2 Replies)
Hi All,
I have two ksh script. 1st script calls the 2nd script and the second script calls an 'C' program.
I want 1st script to wait until the 'C' program completes.
I cant able to get the process id for the 'C' program (child process) to make the 1st script to wait for the second... (7 Replies)
Hey all, I need to launch a script from within 2 other scripts that can run independently of the two parent scripts... Im having a hard time doing this, if anyone knows how please let me know.
More detail.
ScriptA (bash), ScriptB (ksh), ScriptC (bash)
ScriptA, launches ScriptB
ScirptB,... (7 Replies)
I'm trying to do a program that makes activate an signal (SINGALARM) when the next child of a son appears but this not works.
I have to caught the next child o the other (pid), to send a singnal which inform a menssage.
It's anything worng in the code?
thanks.
the code:
#include... (2 Replies)
Hello. I want to make a child do some stuff,wait,then the parent does some stuff and then child does some stuff and waits again.I have made the following but it does not work.Can anybody help me?
pid1 = fork();
if (pid1 == -1)
{
perror("Can't create child\n");
... (18 Replies)
Hi, i want that the parent process start before the child, this code doesn't work,
if the child start before the parent it wait for signal, then the father send the signal SIGALRM and the child catch it and call printf;
else the father call printf and send the signal to the child that call its... (1 Reply)
Hello, everyone.
Here's a program:
pid_t pid = fork();
if (0 == pid) // child process
{
execvp ...;
}
I send a signal (such as SIGINT) to the parent process, the child process receive the signal as well as the parent process.
However I don't want to child process to receive the... (7 Replies)
Hi everyone
i am very new to linux , working on bash shell.
I am trying to solve the given problem
1. Create a process and then create children using fork
2. Check the Status of the application for successful running.
3. Kill all the process(threads) except parent and first child... (2 Replies)
Discussion started by: vizz_k
2 Replies
LEARN ABOUT OPENSOLARIS
kill
kill(2) System Calls kill(2)NAME
kill - send a signal to a process or a group of processes
SYNOPSIS
#include <sys/types.h>
#include <signal.h>
int kill(pid_t pid, int sig);
DESCRIPTION
The kill() function sends a signal to a process or a group of processes. The process or group of processes to which the signal is to be
sent is specified by pid. The signal that is to be sent is specified by sig and is either one from the list given in signal (see sig-
nal.h(3HEAD)), or 0. If sig is 0 (the null signal), error checking is performed but no signal is actually sent. This can be used to check
the validity of pid.
The real or effective user ID of the sending process must match the real or saved (from one of functions in the exec(2) family) user ID of
the receiving process, unless the privilege {PRIV_PROC_OWNER} is asserted in the effective set of the sending process (see Intro(2)), or
sig is SIGCONT and the sending process has the same session ID as the receiving process. A process needs the basic privilege
{PRIV_PROC_SESSION} to send signals to a process with a different session ID. See privileges(5).
If pid is greater than 0, sig will be sent to the process whose process ID is equal to pid.
If pid is negative but not (pid_t)-1, sig will be sent to all processes whose process group ID is equal to the absolute value of pid and
for which the process has permission to send a signal.
If pid is 0, sig will be sent to all processes excluding special processes (see Intro(2)) whose process group ID is equal to the process
group ID of the sender.
If pid is (pid_t)-1 and the {PRIV_PROC_OWNER} privilege is not asserted in the effective set of the sending process, sig will be sent to
all processes excluding special processes whose real user ID is equal to the effective user ID of the sender.
If pid is (pid_t)-1 and the {PRIV_PROC_OWNER} privilege is asserted in the effective set of the sending process, sig will be sent to all
processes excluding special processes.
RETURN VALUES
Upon successful completion, 0 is returned. Otherwise, -1 is returned, no signal is sent, and errno is set to indicate the error.
ERRORS
The kill() function will fail if:
EINVAL The sig argument is not a valid signal number.
EPERM The sig argument is SIGKILL and the pid argument is (pid_t)-1 (that is, the calling process does not have permission to send the
signal to any of the processes specified by pid).
The effective user of the calling process does not match the real or saved user and the calling process does not have the
{PRIV_PROC_OWNER} privilege asserted in the effective set, and the calling process either is not sending SIGCONT to a process
that shares the same session ID or does not have the {PRIV_PROC_SESSION} privilege asserted and is trying to send a signal to a
process with a different session ID.
ESRCH No process or process group can be found corresponding to that specified by pid.
USAGE
The sigsend(2) function provides a more versatile way to send signals to processes.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
|MT-Level |Async-Signal-Safe |
+-----------------------------+-----------------------------+
SEE ALSO kill(1), Intro(2), exec(2), getpid(2), getsid(2), setpgrp(2), sigaction(2), sigsend(2), signal(3C), signal.h(3HEAD), attributes(5), privi-
leges(5), standards(5)SunOS 5.11 22 Mar 2004 kill(2)