This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

how to get a pid from an exe

Old posts that have not been replied to for several years.
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

how to get a pid from an exe

Post by Ofloo »

how do i retreve a pid of a running proces ??

http://dev.scriptics.com/man/tcl8.4/TclCmd/pid.htm

don't realy understand what is meanth by it ... could someone explain closer on how to use it or give an example ? so i can understand ?
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

putserv "privmsg #sheep :hello my pid is [pid]"
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

euhm so if i run an exec from tcl i can echo the pid like that ?
User avatar
ReaLz
Op
Posts: 121
Joined: Sat Oct 19, 2002 5:33 am
Location: Athens, Greece

Post by ReaLz »

yes you can
«A fantastic spaghetti is a spaghetti that does not exist»
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

well this is nice but it only shows the eggdrop.exe pid ?? And not the pid of an exec filename.exe .... nice to know but not exaclty what i was looking for ;) hehe
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

You should have asked about getting the pid of the new process then. As a matter of fact, you can, but as it says on the help page for "pid" you can't do it with exec. Use the "open" command to run the program and then use the "pid" command with the file handle that open returns to get the child process's pid.

set fp [open "|someprogram arg1 arg2" "r+"]
putserv "privmsg #sheep :pid of child is [pid $fp]"

You'll have to change your program some because open and exec work a bit differently.
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

means open also that it is executed ? ? or is that just a part of the proc file ?
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Read the help page for "open"
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

See this page..
Once the game is over, the king and the pawn go back in the same box.
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

oh it is like monitor .. ? like if your gone do lots of stuff with the file or refering to the to the file .. you can use this ?? open thing ? then exec ... ?
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Open can run a program just like exec, except it makes the other program run in the background.

So if you use open, you don't also use exec.

Read the part of the help page for open titled "COMMAND PIPELINES."
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

oh i think that is what i wanted tnx nice thing so from the start i use open the program runs ???
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

ok nice works just one more question how do i make an even when the exe ends ?
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

fileevent should work nicely if you configure the handle for nonblocking operations, or you can use a while loop with 'eof' and 'gets' to poll for it.
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

hmm i think i know what you mean and its not a while but it seems if i use open the eggy keeps open the file ... so wen it ends it is still running but .. the program is not active no more so .. ? maybe it is an error in the exe it self :/ don't realy know but it should close by it self .. :/ it normaly does, is it possible that the eggy keeps the file open ?
Locked