Implement $PPID, the parent process ID of the shell.
This commit is contained in:
parent
f63d6dbfc9
commit
39dccc6f6d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=97689
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user