Solved

Killing an exec'ed process

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Java core in Solaris 10 1 295
NTP Server in VMware 5 285
cron job says it ran, no results 25 120
ORA-00972: identifier is too long from Unix but not from Windows in SQLPLUS 17 98
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
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…

839 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