All Forums |
Register |
Login |
Search |
Subscriptions |
My Profile |
Inbox |
Tool Warehouse |
FAQs |
Resources |
Help |
Member List |
Address Book |
Logout |
|
|
Win32 process id from Interix process id
|
Logged in as: Guest |
Users viewing this topic: none |
|
Login |
|
|
Win32 process id from Interix process id - Sep. 6, '06, 6:17:56 AM
|
|
|
james_bray
Posts: 14
Joined: Dec. 8, '05,
From: Lincolnshire, UK
Status: offline
|
Hi,
Could you tell me if an SFU utility exists to convert an Interix process id, i.e. the process id of an Interix application as shown from "ps", to the associated Win32 process id, i.e. the same process shown in Task Manager.
TIA,
James Bray
Badley Geoscience Limited
|
|
|
RE: Win32 process id from Interix process id - Sep. 6, '06, 7:29:53 AM
|
|
|
eperea
Posts: 70
Joined: Apr. 6, '05,
Status: offline
|
I believe /common/ps.exe shows the same process id as Task Manager, if that will do.
|
|
|
RE: Win32 process id from Interix process id - Sep. 6, '06, 7:42:58 AM
|
|
|
james_bray
Posts: 14
Joined: Dec. 8, '05,
From: Lincolnshire, UK
Status: offline
|
Thanks for the info eperea.
However, I wasnt very clear - I actually need to be able to get the Win32 process id for the *current* Interix process. So I guess I either need an API call I can make to get the process id (obviously cant use Win32 API), or an Interix utility that will convert an Interix process id to the corresponding Win32 process id.
James
|
|
|
RE: Win32 process id from Interix process id - Sep. 6, '06, 1:06:31 PM
|
|
|
Rodney
Posts: 3695
Joined: Jul. 9, '02,
From: /Tools lab
Status: offline
|
There's no API to do this.
Unix and Win32 work with process id's so differently.
A Unix process exec()'s and the PID will remain the same. Not so for Win32
since there is no exec(). Also Win32 doesn't worry about zombies (which
keeps a PID after the process is gone) and recycles the PID's quickly.
What is the purpose for doing this?
Maybe another approach can yield what you want.
|
|
|
RE: Win32 process id from Interix process id - Sep. 6, '06, 2:22:40 PM
|
|
|
markfunk
Posts: 669
Joined: Mar. 31, '03,
Status: offline
|
pseudo C code in Interix:
// find the NT process id from the current process
#include <sys/procfs.h>
int ntpid;
int x, fd;
psinfo_t psinfo;
char psfile[100];
x = getpid(); // get current process id
sprintf(psfile, "/proc/%d/psinfo", x);
fd = open(psfile);
read(fd, &psinfo, sizeof(psinfo));
ntpid = psinfo.pr_natpid;
or, in a ksh script:
# print out the NT process id of the current shell process
/bin/grep natpid /proc/$$/stat | /bin/awk '{print $2}'
|
|
|
RE: Win32 process id from Interix process id - Sep. 7, '06, 5:45:22 AM
|
|
|
james_bray
Posts: 14
Joined: Dec. 8, '05,
From: Lincolnshire, UK
Status: offline
|
Thanks a million mark, using the "stat" information from /proc worked a treat!
Rodney, the reason I need the process id is because I am managing licenses for a collection of Interix processes, and I need to know when a process has died unexpectedly so I can release the license on it's behalf.
Cheers,
James Bray
|
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
|
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts |
|
|
|