Solved

Killing an exec'ed process

Posted on 2000-03-14
1
263 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
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…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now