LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 02-01-2013, 03:55 PM   #1
Hoxygen232
Member
 
Registered: Jan 2013
Posts: 37

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


Hi,

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 script.sh!

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!

Thanks

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

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
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:
Code:
your-program
    \_ bash                 -invoked by the system library function
        \_command3          -invoked by bash
            \_command2
                \_command1
BTW, this sort of sounds like a homework assignment...

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


Reply



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 02:44 PM
how to kill or clean a Uninterruptible slept session leader process from process tabl golden_boy615 Linux - General 1 12-14-2010 10:47 AM
bash `kill`: process 'B' silently dies; but process 'A' = `kill` spews back debris! GrapefruiTgirl Programming 9 06-23-2009 09:42 AM
Shell Script : Kill a running process when another process starts ashmew2 Linux - General 3 08-20-2008 03:47 AM
how to use kill to kill a batch of processes with same name? dr_zayus69 Linux - Software 2 09-03-2005 06:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:46 PM.

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