Finding process id of subsequent process


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Finding process id of subsequent process
# 8  
Old 11-06-2009
thmnetwork - many thanks for the continued reply

this is how it goes,
envVarSetter dataCrunch.exe

I can only capture the pid of envVarSetter and not the pid of dataCrunch.exe as the latter would be spawned as the child of envVarSetter and not as the child of main spawner / controller

So collecting pid here
1) is not useful for checking the status of process whether its running or not
2) or for creating a lock files because lock file would be created before the actual process is spawned.

For ex:

This is how the process is spawned in sequence.
Code:
echo $running_no > $lock_file ; envVarSetter dataCrunch.exe; rm $lock_file

Here, how can I fit the usage of pids here.
If I have not explained properly or improperly please do let me know

thanks Smilie
# 9  
Old 11-06-2009
I'm going to add more to this post later, but one idea would be to spawn another process in your serialized command there that does nothing but wait a second and then quickly looks for the envVarSetter located underneath your parent script, and take its pid out that way. Or you may find your solution by leveraging process grouping (I'm assuming from "init" that this is unix anyways.)

UPDATE

Ok, experimenting with perl child processes a bit on Aix 5.2 it looks like both tty and nice values are inherited by children even after the parent gets cruelly kill -9'd.

This opens the door for possible additional differentiation if you launch envVarSeter via the "nice" command. in additon to time, command, and username(if variable) criteria you can add the tty (if variable) and a randomly generated nice value. You could even store the last three or four generated nice values. That requires a collision to be between dataCrunchers launched with three or four others in the same second, under the same username, on the same tty, and with the same randomly generated nice value. I think that sufficiently would shrink the collision domain for us unless you have one hellacious load level. After you find the PID by the criteria after the fact you can re-adjust the nice's to production levels.

The main obstacle I can see is if envVarSetter clobbers the nice value. You'll probably want to find a way to run the command from the command line in a non-destructive way. Not sure what dataCruncher.exe or envVarSetter are so you're probably on your own as far as whether "coding the nice level" will work. If you could find something within process groups that works, that would probably be more ideal for you.

Last edited by thmnetwork; 11-06-2009 at 08:33 PM..
# 10  
Old 11-09-2009
probably process group is a nice idea. I will try evaluating in that domain.

Regarding nice value, tty inheritance - there is a potential problem if I rely on them.

I am trying to frame a generic script and the multiple chunks that are being executed, needlessly might turn out to a be a daemon therefore

1) detaching itself from a tty
2) altering the nice value
3) can switch between multiple process groups

the above is not something frequent but the generic capability of the script will be affected.

Am really wondering, is n't there an easy way to track child process by the parent - condition being parent is short lived and child being inherited by init.

Thanks again Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Finding a file process ?

Hi, I am trying to find a file that have a different name than it should be processing, the file name is ( Fifa15 ) is there a command to use? I got that file by ps -ef | grep fifa15 but how do I know what is running ? thanks a lot, I am learning unix so sorry if that is a... (2 Replies)
Discussion started by: latinooo
2 Replies

2. Shell Programming and Scripting

Finding process which ended another process

Hello, The scenario is as follows, I have a background process running initially for which i know the PID on machine1. I use ssh from machine 2 to execute a script in machine 1. For some reason the back ground process is terminated. I would like to know which process caused the... (6 Replies)
Discussion started by: prasbala
6 Replies

3. UNIX for Dummies Questions & Answers

Finding a rogue process

Afternoon all, hopefully someone can give me a hand with this (the following may be explained very poorly :rolleyes: ) I know there's a process running on one of our Solaris 10 boxes that runs approximately every 5 minutes. Unfortunately I've no idea, who owns it, what it is called, or how it is... (2 Replies)
Discussion started by: dlam
2 Replies

4. Shell Programming and Scripting

Finding the process id of the process using the ports

Hi Any idea how to get the process id of the process using the ports lsof -i :portnumber does not work in my machine. I am on sun Solaris SPARC. Any suggestion is highly appreciated (1 Reply)
Discussion started by: kinny
1 Replies

5. Linux

Need help in finding process

Hello, Iam running a apache webserver in CentOS recenlty a hacker has attacked my server using RFI attack and did something in my server.. After that everyday at 8Pm my httpd is using about 5000 pid's actually in normal it takes only about 30 - 40 pid's. and also exim uses 2000 pid's totally my... (2 Replies)
Discussion started by: dheeraj4uuu
2 Replies

6. Shell Programming and Scripting

finding Background Process Id

Hi Gurus, How can i find background process is completed or not. I have mentioned my scenario below. Actually Pr1 Process is running in back ground, i just want to know whether this process completed or not. I can come to know the process id by typing pid=$! but i want to trigger... (4 Replies)
Discussion started by: krk_555
4 Replies

7. UNIX for Dummies Questions & Answers

Finding out process id in a scipt

Hi, If in a shell script i write a command ls > bla & ls The output is redirected to bla and the next ls starts as first one is going on in background. I want to find the PID of the first command. Thanks in advance (2 Replies)
Discussion started by: vibhor_agarwali
2 Replies

8. UNIX for Dummies Questions & Answers

finding process id

is there a way to find the process id of a process because i have same process invoked several times. when i need to kill them, i get confused with the id. Thanks, sskb :( (8 Replies)
Discussion started by: sskb
8 Replies

9. UNIX for Advanced & Expert Users

Finding Out When A Process Has Finished?

Problem I have an application which basically runs lots of UNIX programs remotely, using the Telnet protocol. For each program it remotely executes, it stores the process ID (PID) for that process. At regular intervals, I would like my application to take the PID for every process still... (5 Replies)
Discussion started by: 1cuervo
5 Replies
Login or Register to Ask a Question