linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Getting pid of exec'd process
@ 2007-03-22 11:11 Prasanta Sadhukhan
  2007-03-22 11:41 ` cyon.john
  2007-03-22 16:31 ` Benoît Rouits
  0 siblings, 2 replies; 3+ messages in thread
From: Prasanta Sadhukhan @ 2007-03-22 11:11 UTC (permalink / raw)
  To: linux-c-programming

Hi,

Can anyone suggest as to how can I get the pid of the process which I 
have done execv()?
ie, if I do execv(path, cmd) a new process will be launched and now how 
can I get the pid of this new process?

Regard
Prasanta


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: Getting pid of exec'd process
  2007-03-22 11:11 Getting pid of exec'd process Prasanta Sadhukhan
@ 2007-03-22 11:41 ` cyon.john
  2007-03-22 16:31 ` Benoît Rouits
  1 sibling, 0 replies; 3+ messages in thread
From: cyon.john @ 2007-03-22 11:41 UTC (permalink / raw)
  To: Prasanta.Sadhukhan, linux-c-programming

Hi,

If you are doing execv after creating a child process using fork, then
return value of fork will give you the pid of the process.

If you haven't done any fork, then the pid is same the calling process
(execv doesn't create any new process, it overwrites the process image
of calling one) and can be obtained using the getpid() system call.

Regards,
Cyon P.J.

-----Original Message-----
From: linux-c-programming-owner@vger.kernel.org
[mailto:linux-c-programming-owner@vger.kernel.org] On Behalf Of Prasanta
Sadhukhan
Sent: Thursday, March 22, 2007 4:42 PM
To: linux-c-programming@vger.kernel.org
Subject: Getting pid of exec'd process

Hi,

Can anyone suggest as to how can I get the pid of the process which I
have done execv()?
ie, if I do execv(path, cmd) a new process will be launched and now how
can I get the pid of this new process?

Regard
Prasanta

-
To unsubscribe from this list: send the line "unsubscribe
linux-c-programming" in the body of a message to
majordomo@vger.kernel.org More majordomo info at
http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Getting pid of exec'd process
  2007-03-22 11:11 Getting pid of exec'd process Prasanta Sadhukhan
  2007-03-22 11:41 ` cyon.john
@ 2007-03-22 16:31 ` Benoît Rouits
  1 sibling, 0 replies; 3+ messages in thread
From: Benoît Rouits @ 2007-03-22 16:31 UTC (permalink / raw)
  To: Prasanta Sadhukhan; +Cc: linux-c-programming

hello Prasanta, maybe you can look at 
http://patatra.mine.nu/cash/cash.tar.gz

it contains a shell of 160 line of code that uses fork() and execvp()
maybe the source code can help you to learn.
Hope this helps.
+ Ben

Le jeudi 22 mars 2007 à 16:41 +0530, Prasanta Sadhukhan a écrit :
> Hi,
> 
> Can anyone suggest as to how can I get the pid of the process which I 
> have done execv()?
> ie, if I do execv(path, cmd) a new process will be launched and now how 
> can I get the pid of this new process?
> 
> Regard
> Prasanta
> 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-03-22 16:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-22 11:11 Getting pid of exec'd process Prasanta Sadhukhan
2007-03-22 11:41 ` cyon.john
2007-03-22 16:31 ` Benoît Rouits

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).