to find current running process


 
Thread Tools Search this Thread
Top Forums Programming to find current running process
# 1  
Old 02-25-2005
to find current running process

Hi All,

The scenario is like this:

There is a process say "A" which create a child process say "B" if some condition is true and process "A" terminates. "B" invokes some C program say "C" using 'execl' function. The job of program "C" is to keep polling the server until the server will be up.

Now, the requirement is, when "A" is called next time, it should check is there any process is running for program "C". If yes then "A" terminates.

My question is: How to find whether the program "C" is running or not in "A" code?

regards,

Ranjeet
# 2  
Old 02-25-2005
Without using root privileges and keeping it simple:

1. you can call popen to execute a shell command like "ps" to find process "C"
if there is a clear way to tell from ps output that process "C" is out there.

or

2. create path/filename that all the programs agree upon, and use it as a lock file.
When "C" starts it writes something like "Process C is running" to the file and closes it.
When process "C" exits it removes the line from the file. All process "A" has to do is read the file to see if "C" is running. Or just have C create an empty file and delete the file when C exits. Then A just checks for the exsitence of the file.
# 3  
Old 03-07-2005
try the following
ps -ef | grep "procname"
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to find out process name that are running for last 10 days.

Hi all, As i am new to shell script.Please help me to write a Shell script to find out process name that are running for last 10 days. Thank's in advance. (8 Replies)
Discussion started by: manas_1988
8 Replies

2. Shell Programming and Scripting

List Process running under current user

Hi, i need to list the processes running only under current logged in user. EX: $ whoami oraaqw $ ps -ef | grep tnslsnr oraaqw 11403300 19267592 0 09:14:47 pts/3 0:00 grep tnslsnr oraaqw 15794208 1 0 Jan 14 - 11:59... (6 Replies)
Discussion started by: aravindadla
6 Replies

3. Shell Programming and Scripting

Command to know all the Current running process and how to kill

All, 1.What is the unix comand used for all current running process (Including All current running processes Parent ->child->subchild process) 2.If child and subchild processes are running then what is the unix command to kill parent and its all child subchild processes in UNIX. Kindly... (7 Replies)
Discussion started by: skp
7 Replies

4. Shell Programming and Scripting

Display current directory for a running process for script

I'm trying to create a ksh script to do the following: 1) Ask the user what process they want to search for. 2) Have the script read the input as a variable and use it to search for the process. 3) Display the current time & date, the working directory of the process, and finally display the... (6 Replies)
Discussion started by: seekryts15
6 Replies

5. Shell Programming and Scripting

Shell Script to find out if a process is running on any all machines

Hi All, I have been a guest visitor from a long time and this forum is wonderful. I finally am a member of this forum too, so i am here stuck with a shell script that i was trying to write My requirement is that i should be able to create a shell script which will check if a process is running on... (3 Replies)
Discussion started by: Rex0226
3 Replies

6. UNIX for Dummies Questions & Answers

Running different process from current process?

I have been having some trouble trying to get some code working, so I was wondering...what system calls are required to execute a different program from an already running process? (1 Reply)
Discussion started by: Midwest Product
1 Replies

7. UNIX for Dummies Questions & Answers

How to find the details of the previously running process with PID

OS: Unix or Linux I (only) know the pid of the process which was running earlier (say 5 hrs back) but it is not running now. Is there a way I could find the details of that process? (atleast the name of the process). Please let me know. (2 Replies)
Discussion started by: vijay.d
2 Replies

8. UNIX for Dummies Questions & Answers

Current Process Running.

Hi all, When I issued command ps -ef|grep Vinay in a UNIX machine, I got the following Vinay 22491 1 255 Jun 18 ? 294248:53 -sh Vinay 26628 1 255 Jun 18 ? 294237:33 -sh Could you tell me what all process is running ? Please explain each of the fields. Thanks... (4 Replies)
Discussion started by: coolbhai
4 Replies

9. Shell Programming and Scripting

current running process in shell

hi what is the shell programming code to know the number of processes currently running on the machine & information about those processes. Another one is the configuration and usage of the UNIX file system? requesting all for help. thanks (1 Reply)
Discussion started by: moco
1 Replies

10. UNIX for Advanced & Expert Users

how to make a current running process ignore SIGHUP signal?

I ask this question since sometimes i run a time-consuming ftp in foreground and forget to use nohup ftp.sh & to put this work background and can still running after i log off. Assume this ftp task have run 1 hour, and still 1 hour time to end, i don't want to abort the ftp, first, i use ctrl+Z... (3 Replies)
Discussion started by: stevensxiao
3 Replies
Login or Register to Ask a Question