Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

information about a process?

Posted on 2003-02-25
13
Medium Priority
?
217 Views
Last Modified: 2012-05-04
I start a fork a new process in my program with execl and I get this process id. Is there a way for me to check and see later in my original program if this process is still running and to get the user id of this process.

0
Comment
Question by:joele23
  • 8
  • 4
13 Comments
 
LVL 2

Author Comment

by:joele23
ID: 8020734
hmm..must be tougher than I thought
0
 
LVL 2

Expert Comment

by:anovickis
ID: 8020765
The answer depends on the system you run it on - perhaps you should elucidate.
0
 
LVL 8

Accepted Solution

by:
mnashadka earned 450 total points
ID: 8021242
On UNIX/Linux you can use waitpid with the WNOHANG parameter (so that you don't block until it does exit).
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 2

Author Comment

by:joele23
ID: 8021600
mnashadka

I dont quite get it. How will this tell me if the process is still running and the user id of this process?
0
 
LVL 8

Expert Comment

by:mnashadka
ID: 8021761
If waitpid returns the process id, that means that there's a status.  There's also a WIFEXITED macro on some systems that will help you tell if the process exited.
Alternatively, each system has it's own calls.  For instance, on Linux you could check to see if there's a directory named /proc/<process id> using access().
0
 
LVL 2

Author Comment

by:joele23
ID: 8026878
this still doenst tell me the user id though. I would think there had to pe a better way.
0
 
LVL 2

Author Comment

by:joele23
ID: 8027650
hmm..still no complete answer so pints going up
0
 
LVL 2

Author Comment

by:joele23
ID: 8027655
my typing skills suck sorry for typos
0
 
LVL 8

Expert Comment

by:mnashadka
ID: 8028092
getuid will get the int user id for the calling process.  Unless the process explicitly calls setuid, the child will have the same user id.
0
 
LVL 2

Author Comment

by:joele23
ID: 8028424
Ok,
but how do I know for sure that when I call waitpid that the process hasnt exited and a different process is running with the same pid. Is there a way to extract the process anme form this too?
0
 
LVL 2

Author Comment

by:joele23
ID: 8028430
by the way Im going to give you the pints I just want to make sure this all works
0
 
LVL 8

Expert Comment

by:mnashadka
ID: 8028457
waitpid will only work with child processes of the current process.
0
 
LVL 2

Author Comment

by:joele23
ID: 8029053
I still think thers a better way but this will  have to work.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
Suggested Courses

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question