Implement $PPID, the parent process ID of the shell.

This commit is contained in:
Tim J. Robbins 2002-06-01 02:14:48 +00:00
parent f63d6dbfc9
commit 39dccc6f6d
2 changed files with 9 additions and 0 deletions

View File

@ -91,6 +91,7 @@ struct var vifs;
struct var vmail;
struct var vmpath;
struct var vpath;
struct var vppid;
struct var vps1;
struct var vps2;
struct var vvers;
@ -116,6 +117,8 @@ const struct varinit varinit[] = {
NULL },
{ &vpath, VSTRFIXED|VTEXTFIXED, "PATH=/bin:/usr/bin",
changepath },
{ &vppid, VSTRFIXED|VTEXTFIXED|VUNSET, "PPID=",
NULL },
/*
* vps1 depends on uid
*/
@ -165,6 +168,7 @@ INIT {
void
initvar(void)
{
char ppid[20];
const struct varinit *ip;
struct var *vp;
struct var **vpp;
@ -189,6 +193,10 @@ initvar(void)
vps1.text = geteuid() ? "PS1=$ " : "PS1=# ";
vps1.flags = VSTRFIXED|VTEXTFIXED;
}
if ((vppid.flags & VEXPORT) == 0) {
fmtstr(ppid, sizeof(ppid), "%d", (int)getppid());
setvarsafe("PPID", ppid, 0);
}
}
/*

View File

@ -78,6 +78,7 @@ extern struct var vifs;
extern struct var vmail;
extern struct var vmpath;
extern struct var vpath;
extern struct var vppid;
extern struct var vps1;
extern struct var vps2;
#if ATTY