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