Solved

Killing an exec'ed process

Posted on 2000-03-14
1
266 Views
Last Modified: 2010-04-21
I have installed a signal handler using sigaction to catch SIGTERM. However the main process vforks, and then execs a new process in the resulting child process.

Is there any way to kill that process which has been exec'ed ? From all the man pages, I know that the exec set of calls resets any signal's dispositions to their default handlers.

Any pointers ?
fstab.
0
Comment
Question by:fstab
1 Comment
 
LVL 14

Accepted Solution

by:
chris_calabrese earned 50 total points
ID: 2617356
Since you know the process number of the child from the return value of vfork(), you can send the child a SIGTERM.

The code would look something like this:

pid_t child_pid=-1;

....

child_pid=vfork();
if(child_pid == 0) {
    /* this is the child */
    execve(.....)
   ...
} else if(child_pid < 0) {
    /* an error occurred */
   perror(...)
   ...
}

....

void handler(int mysig) {
    ...
    if(child_pid > 0)
        kill(child_pid, mysig)
    ...
}

....

signal(SIGTERM, handler);

....
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
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…

786 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