Monday, 15 February 2010

c - From where my executable is called -



c - From where my executable is called -

i have 'c' executable c_out , can executed 2 different scripts scripta , scriptb. there way can find out in c_out script executed me? there no arguments passed c_out want find out executed c_out.

here's quick way determine on linux.

#include <stdio.h> int main(int argc, char* argv[]) { int ppid = 0; char syscmd[32]; ppid = getppid(); sprintf(syscmd,"cat /proc/%d/cmdline\n",ppid); system(syscmd); homecoming 0; }

~

c bash shell

No comments:

Post a Comment