?
Solved

information about a process?

Posted on 2003-02-25
13
Medium Priority
?
216 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
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…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

762 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