LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 12-12-2007, 03:28 PM   #1
kaz2100
Senior Member
 
Registered: Apr 2005
Location: Penguin land, with apple, no gates
Distribution: Debian testing woody(32) sarge etch lenny squeeze(+64) wheezy jessie
Posts: 1,445

Rep: Reputation: 83
How to get a job ID of grand child process? (tcsh script)


Hya,

I am trying to write a sort of simple shell script, which
1) opens one window and send to background (child), then
2) does something interactive on original window (parent), and
3) closes child window then
4) exits.

To do step 3, I need to know Job ID of child process.

I use tcsh.

I thought that $! would work, but the command at step 1 looks like
Code:
find $1 -name $2 -exec doCommand \; &
so that $! looks like to hold process ID of "find" command, (instead of doCommand)

So, at this moment I have
Code:
kill `ps -e | grep $! | grep doCommand | tr -s ' ' | cut -f 2 -d ' '`
at step 3.

This code does not look good and difficult to read....

Is there any better way to get process ID of grand child??

Happy Penguins!
 
Old 12-12-2007, 06:12 PM   #2
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,289

Rep: Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034
When you background a cmd like this
./t.sh &
[2] 937
as you can see, the 2nd rtn value is the pid of the backgrounded cmd, so just capture that.
 
  


Reply

Tags
child, id, process, tcsh


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
how a father process know which child process send the signal SIGCHLD icoming Programming 10 07-20-2010 07:26 AM
How to kill a Child and all its subsequent child process in C shayer009 Programming 3 12-04-2007 12:40 AM
child process usses same amount of ram as parent process socialjazz Programming 7 10-19-2006 05:48 PM
Killing a child process from another child marri Programming 6 10-01-2004 07:08 PM
Bash Scripting - child process affecting parent process mthaddon Linux - General 1 05-02-2004 01:19 PM


All times are GMT -5. The time now is 04:15 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration