In C Program, determine if job is running


 
Thread Tools Search this Thread
Top Forums Programming In C Program, determine if job is running
# 8  
Old 06-30-2006
All I'm saying is that ps on some systems invokes kernel mode code. I agree that spawning a process for this from C is a bad idea, but until the OP learns internals and systems calls he cannot get away from ps..
# 9  
Old 07-03-2006
Quote:
Originally Posted by jim mcnamara
All I'm saying is that ps on some systems invokes kernel mode code. I agree that spawning a process for this from C is a bad idea, but until the OP learns internals and systems calls he cannot get away from ps..

get the processid, and send signal-0 to that processid
if return value is equal to 0, process is available else its not available,

here there is no need to spawn a process with system call,

isn't this better ???
# 10  
Old 07-03-2006
Quote:
Originally Posted by Hitori
I dont think that executing the shall command "ps -ef | grep 'job_name' | grep -v grep" is the best idia to solve this task. There are must be appropriate solution in C. (I've used Linux in general and prefer to use /proc)
else,
if you dont accept what Jim said,

i believe you should read the kernal internal data structure- process table as such ... which is done by ps.

And the code should itself switch to kernal mode to become permissible to read the process table and its entries
# 11  
Old 07-03-2006
Quote:
Originally Posted by matrixmadhan
else,
i believe you should read the kernal internal data structure- process table as such ... which is done by ps.
not all ps implementations do so Smilie

Quote:
Originally Posted by matrixmadhan
And the code should itself switch to kernal mode to become permissible to read the process table and its entries
Thanks, I'll try
# 12  
Old 07-03-2006
Quote:
not all ps implementations do so
i didnt mean it that way...

my intention was just to say.. read the kernel data structure - process table and its entries

the usage ps is just an example and not a standard
# 13  
Old 07-16-2006
the unix programming faq contains sample programms for that. on linux it can be done by
searching /proc
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Perl : Inline program to determine file size

Hi, I have 5 files as below $ ll sam* -rw-rw-rw- 1 sam ugroup 0 Mar 21 06:06 sam3 -rw-rw-rw- 1 sam ugroup 0 Apr 3 22:41 sam2 -rw-rw-rw- 1 sam ugroup 17335 Apr 10 06:07 sam1 -rw-rw-rw- 1 sam ugroup 5 Apr 10 07:53 sam5 -rw-rw-rw- 1 sam ugroup 661 Apr 10 08:16 sam4 I want to list out... (4 Replies)
Discussion started by: sam05121988
4 Replies

2. Solaris

Cron job is not running

Hi, I have set up the crontab as follows. root@IDC4VASAPP07 # crontab -l 0-59 * * * * /var/tmp/r.sh 0-59 * * * * date >> /var/tmp/log root@IDC4VASAPP07 # r.sh is as follows. root@IDC4VASAPP07 # cat r.sh #!/bin/bash dt1=$(perl -e 'use POSIX;print strftime... (10 Replies)
Discussion started by: SunilB2011
10 Replies

3. Shell Programming and Scripting

cron job and running program

Dear experts, I have this cronjob * */2 * * * $path/supervisor.sh The supervisor script is checking another script, which initializes the final scripts in multiple directories. Note that the supervisor script runs without the cronjob. In each directory, I have the following script: ... (2 Replies)
Discussion started by: TheTransporter
2 Replies

4. Shell Programming and Scripting

determine the active processes on the system which are running since long time

Hi , Please help me shell script to determine the active processes on the system which are running since long time (2 Replies)
Discussion started by: itian2010
2 Replies

5. UNIX for Advanced & Expert Users

How to determine the number of NFS threads RUNNING on the system

Hi, Anyone can tell me how to get the number of NFS threads RUNNING on the system for Solaris 10? Someone told me for Solaris 9, the method is "echo "*svc$<svcpool" | adb -k. But, I've tried to google the method for Solaris 10 and did not find the corresponding method, please help... (1 Reply)
Discussion started by: wang.caiqi
1 Replies

6. UNIX for Dummies Questions & Answers

Cron job not running

Hi All, I am editing crontab using -e option to add a new job Below is the line 30 * * * * scriptpath This job is not executing every thirty minutes. I have checked, cron daemon is running. What did I miss? Can some one help? I am using cron shell..ksh (7 Replies)
Discussion started by: yabhi_22
7 Replies

7. Shell Programming and Scripting

Determine Number of Processes Running

I am pretty new to unix, and I have a project to do. Part of the project asks me to determine the number of processes running and assign it to a variable. I know how to every part of the project but determine the number of processes running. How can I get just the number of processes... (4 Replies)
Discussion started by: wayne1411
4 Replies

8. Shell Programming and Scripting

How to determine if a script (perl) was called from a CRON job or commandline

Hi, Is there a way to determine if a Script is called from a CRON job or from a commandline Gerry. (2 Replies)
Discussion started by: jerryMcguire
2 Replies

9. Shell Programming and Scripting

Hw to Know the status of running JoB

Hi all, I am running a job .. and i want to know the status tht it is runnig or not .. and how can i find the jobId of my job .. I have to get it to kill my running job Pls let me know da Unix commands to do it .. i m wrking on Hp UNIX (1 Reply)
Discussion started by: ravi.sadani19
1 Replies

10. Shell Programming and Scripting

Backup with shell program and cron job.

Hi, The object of my program is to take automatic backup on daily basis to different folders. I have created the respective folders. when I execute below given shell program manually it is working perfectly and taking the backup to respective folder. #!/bin/sh #script to take backup on... (1 Reply)
Discussion started by: jarkvarma
1 Replies
Login or Register to Ask a Question