Becoming parent ...

Boyd Roberts boyd at necisa.ho.necisa.oz
Mon Nov 5 14:50:28 AEST 1990


In article <24928 at adm.BRL.MIL> MANNS%DBNPIB5.BITNET at cunyvm.cuny.edu (Jochen Manns, PI der Uni Bonn, 732738/3611) writes:
>
>        - is it possible for a process to become a processes parent? In

No, the parent/child child relationship can only be created via fork(2).
You can't re-parent an arbitary process.  Of course, init (process 1) is
a special case.  Processes whose parent exits before them have their
parent process id change to be that of init when the parent exits.

>        - is there a way to access (argc,argv) from anywhere in a program?

Yes, declare:

    int  gargc;
    char *gargv[];

as globals and in main() go:

    main(argc, argv)
    int  argc;
    char *argv[];
    {
	gargc = argc;
	gargv = argv;

	...
    }

Isn't this one a FAQ in comp.lang.c?


Boyd Roberts			boyd at necisa.ho.necisa.oz.au

``When the going gets wierd, the weird turn pro...''



More information about the Comp.unix.questions mailing list