Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 02-01-2013, 04:55 PM   #1
Registered: Jan 2013
Posts: 37

Rep: Reputation: Disabled
Processes control, communication - kill next process and resume it


I made a C program that calls bash script files .sh by using "system(" ");", in this program the process father forks 3 processes (1. 2. 3.).
What I'd like to add to my program is:
- when the father forks the third process it does a "wait" ( wait (&status); )
- at that point the third process will be executing, but before executing it I want to use a script that gets the next (process 3.) process's PID in order to kill it.
- after that, the control returns to the father process (because its son has been killed), so the father has to restore the process 3. (that was previously killed) by using another!

That's it.
Summarizing, what I need to do is doing "processes concurrency"
I have to create processes that don't have to wait for other processes to finish, but they have to start meanwhile other processes make part of output available for them in order to use that output. In this way I will have "mutual communication" using "kill" bash command.

I hope it's clear!


Last edited by Hoxygen232; 02-01-2013 at 06:11 PM.
Old 02-02-2013, 02:40 PM   #2
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,714

Rep: Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280
Not clear.

Note - using the "system" function will wait until the command given is processed.

To execute that command the parent process forks and executes the shell, which then processes the command.

So if that command then causes three commands to be executed (such as a pipe), then it will wait for the last of those commands to finsh.

So the process tree is:
    \_ bash                 -invoked by the system library function
        \_command3          -invoked by bash
BTW, this sort of sounds like a homework assignment...

Last edited by jpollard; 02-02-2013 at 02:41 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Kill a zombie process - which process is the parent that I should kill? Mountain Linux - General 3 12-31-2011 03:44 PM
how to kill or clean a Uninterruptible slept session leader process from process tabl golden_boy615 Linux - General 1 12-14-2010 11:47 AM
bash `kill`: process 'B' silently dies; but process 'A' = `kill` spews back debris! GrapefruiTgirl Programming 9 06-23-2009 10:42 AM
Shell Script : Kill a running process when another process starts ashmew2 Linux - General 3 08-20-2008 04:47 AM
how to use kill to kill a batch of processes with same name? dr_zayus69 Linux - Software 2 09-03-2005 07:35 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:01 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration