?
Solved

Killing an exec'ed process

Posted on 2000-03-14
1
Medium Priority
?
270 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 14

Accepted Solution

by:
chris_calabrese earned 150 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
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…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Suggested Courses
Course of the Month10 days, 5 hours left to enroll

762 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