in reply to Re: Find name of calling script?
in thread Find name of calling script?

On Windows the Perl getppid is not implemented. I have used the following C code in some of my XS modules:
#include <windows.h> #include <tlhelp32.h> static int getppid(void) { HANDLE hToolSnapshot; PROCESSENTRY32 Pe32 = {0}; BOOL bResult; DWORD PID; DWORD PPID = 0; PID = GetCurrentProcessId (); hToolSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (hToolSnapshot == INVALID_HANDLE_VALUE) { return 0; } Pe32.dwSize = sizeof(PROCESSENTRY32); bResult = Process32First(hToolSnapshot, &Pe32); if (!bResult) return 0; while ( Process32Next(hToolSnapshot, &Pe32) ) { if (Pe32.th32ProcessID == PID) { PPID = Pe32.th32ParentProcessID; break; } } /* Expected */ if (GetLastError() == ERROR_NO_MORE_FILES) { SetLastError(ERROR_SUCCESS); } return PPID; }
Ah, I see you have upgraded to Linux, maybe it might be useful to some poor Windows coder.