mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
This variable is like Bash's $BASHPID, but in virtual subshells
it will retain its previous value as virtual subshells don't fork.
Both $BASHPID and ${.sh.pid} are different from $$ as the latter
is only set to the parent shell's process ID (i.e. it isn't set
to the process ID of the current subshell).
src/cmd/ksh93/include/defs.h:
- Add 'current_pid' for storing the current process ID at a valid
memory address.
- Change 'ppid' from 'int32_t' to 'pid_t', as the return value from
'getppid' is of the 'pid_t' data type.
src/cmd/ksh93/data/variables.c,
src/cmd/ksh93/include/variables.h,
src/cmd/ksh93/sh/init.c,
src/cmd/ksh93/sh/xec.c:
- Add the ${.sh.pid} variable as an alternative to $BASHPID.
The process ID is stored in a struct before ${.sh.pid} is set
as environment variables are pointers that must point to a
valid memory address. ${.sh.pid} is updated by the _sh_fork()
function, which is called when ksh forks a new process with
sh_fork() or sh_ntfork().
src/cmd/ksh93/tests/variables.sh:
- Add ${.sh.pid} to the list of special variables and add three
regression tests for ${.sh.pid}.
src/cmd/ksh93/tests/subshell.sh:
- Update the PATH forking regression test to use ${.sh.pid} and
remove the TODO note.
96 lines
4.2 KiB
C
96 lines
4.2 KiB
C
/***********************************************************************
|
|
* *
|
|
* This software is part of the ast package *
|
|
* Copyright (c) 1982-2011 AT&T Intellectual Property *
|
|
* and is licensed under the *
|
|
* Eclipse Public License, Version 1.0 *
|
|
* by AT&T Intellectual Property *
|
|
* *
|
|
* A copy of the License is available at *
|
|
* http://www.eclipse.org/org/documents/epl-v10.html *
|
|
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
|
|
* *
|
|
* Information and Software Systems Research *
|
|
* AT&T Research *
|
|
* Florham Park NJ *
|
|
* *
|
|
* David Korn <dgk@research.att.com> *
|
|
* *
|
|
***********************************************************************/
|
|
#pragma prototyped
|
|
|
|
#ifndef SH_VALNOD
|
|
|
|
#include <option.h>
|
|
#include "FEATURE/options"
|
|
#include "FEATURE/dynamic"
|
|
|
|
/* The following defines are coordinated with data in data/variables.c */
|
|
|
|
#define PATHNOD (shgd->bltin_nodes)
|
|
#define PS1NOD (shgd->bltin_nodes+1)
|
|
#define PS2NOD (shgd->bltin_nodes+2)
|
|
#define IFSNOD (shgd->bltin_nodes+3)
|
|
#define PWDNOD (shgd->bltin_nodes+4)
|
|
#define HOME (shgd->bltin_nodes+5)
|
|
#define MAILNOD (shgd->bltin_nodes+6)
|
|
#define REPLYNOD (shgd->bltin_nodes+7)
|
|
#define SHELLNOD (shgd->bltin_nodes+8)
|
|
#define EDITNOD (shgd->bltin_nodes+9)
|
|
#define MCHKNOD (shgd->bltin_nodes+10)
|
|
#define RANDNOD (shgd->bltin_nodes+11)
|
|
#define ENVNOD (shgd->bltin_nodes+12)
|
|
#define HISTFILE (shgd->bltin_nodes+13)
|
|
#define HISTSIZE (shgd->bltin_nodes+14)
|
|
#define HISTEDIT (shgd->bltin_nodes+15)
|
|
#define HISTCUR (shgd->bltin_nodes+16)
|
|
#define FCEDNOD (shgd->bltin_nodes+17)
|
|
#define CDPNOD (shgd->bltin_nodes+18)
|
|
#define MAILPNOD (shgd->bltin_nodes+19)
|
|
#define PS3NOD (shgd->bltin_nodes+20)
|
|
#define OLDPWDNOD (shgd->bltin_nodes+21)
|
|
#define VISINOD (shgd->bltin_nodes+22)
|
|
#define COLUMNS (shgd->bltin_nodes+23)
|
|
#define LINES (shgd->bltin_nodes+24)
|
|
#define PPIDNOD (shgd->bltin_nodes+25)
|
|
#define L_ARGNOD (shgd->bltin_nodes+26)
|
|
#define TMOUTNOD (shgd->bltin_nodes+27)
|
|
#define SECONDS (shgd->bltin_nodes+28)
|
|
#define LINENO (shgd->bltin_nodes+29)
|
|
#define OPTARGNOD (shgd->bltin_nodes+30)
|
|
#define OPTINDNOD (shgd->bltin_nodes+31)
|
|
#define PS4NOD (shgd->bltin_nodes+32)
|
|
#define FPATHNOD (shgd->bltin_nodes+33)
|
|
#define LANGNOD (shgd->bltin_nodes+34)
|
|
#define LCALLNOD (shgd->bltin_nodes+35)
|
|
#define LCCOLLNOD (shgd->bltin_nodes+36)
|
|
#define LCTYPENOD (shgd->bltin_nodes+37)
|
|
#define LCMSGNOD (shgd->bltin_nodes+38)
|
|
#define LCNUMNOD (shgd->bltin_nodes+39)
|
|
#define FIGNORENOD (shgd->bltin_nodes+40)
|
|
#define VERSIONNOD (shgd->bltin_nodes+41)
|
|
#define JOBMAXNOD (shgd->bltin_nodes+42)
|
|
#define DOTSHNOD (shgd->bltin_nodes+43)
|
|
#define ED_CHRNOD (shgd->bltin_nodes+44)
|
|
#define ED_COLNOD (shgd->bltin_nodes+45)
|
|
#define ED_TXTNOD (shgd->bltin_nodes+46)
|
|
#define ED_MODENOD (shgd->bltin_nodes+47)
|
|
#define SH_NAMENOD (shgd->bltin_nodes+48)
|
|
#define SH_SUBSCRNOD (shgd->bltin_nodes+49)
|
|
#define SH_VALNOD (shgd->bltin_nodes+50)
|
|
#define SH_VERSIONNOD (shgd->bltin_nodes+51)
|
|
#define SH_DOLLARNOD (shgd->bltin_nodes+52)
|
|
#define SH_MATCHNOD (shgd->bltin_nodes+53)
|
|
#define SH_COMMANDNOD (shgd->bltin_nodes+54)
|
|
#define SH_PATHNAMENOD (shgd->bltin_nodes+55)
|
|
#define SH_FUNNAMENOD (shgd->bltin_nodes+56)
|
|
#define SH_SUBSHELLNOD (shgd->bltin_nodes+57)
|
|
#define SH_LEVELNOD (shgd->bltin_nodes+58)
|
|
#define SH_LINENO (shgd->bltin_nodes+59)
|
|
#define SH_STATS (shgd->bltin_nodes+60)
|
|
#define SH_MATHNOD (shgd->bltin_nodes+61)
|
|
#define SH_JOBPOOL (shgd->bltin_nodes+62)
|
|
#define SH_PIDNOD (shgd->bltin_nodes+63)
|
|
#define SHLVL (shgd->bltin_nodes+64)
|
|
|
|
#endif /* SH_VALNOD */
|