Win32 process id from Interix process id (Full Version)

All Forums >> [SFU / Interix / SUA Technology] >> Interix Advanced Forum



Message


james_bray -> Win32 process id from Interix process id (Sep. 6, '06, 6:17:56 AM)

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




eperea -> RE: Win32 process id from Interix process id (Sep. 6, '06, 7:29:53 AM)

I believe /common/ps.exe shows the same process id as Task Manager, if that will do.




james_bray -> RE: Win32 process id from Interix process id (Sep. 6, '06, 7:42:58 AM)

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




Rodney -> RE: Win32 process id from Interix process id (Sep. 6, '06, 1:06:31 PM)

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.




markfunk -> RE: Win32 process id from Interix process id (Sep. 6, '06, 2:22:40 PM)

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}'




james_bray -> RE: Win32 process id from Interix process id (Sep. 7, '06, 5:45:22 AM)

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




Page: [1]



Forum Software © ASPPlayground.NET Advanced Edition 2.5 ANSI

0.063