diff options
author | April Chin <April.Chin@Sun.COM> | 2008-12-27 14:59:38 -0800 |
---|---|---|
committer | April Chin <April.Chin@Sun.COM> | 2008-12-27 14:59:38 -0800 |
commit | 7c2fbfb345896881c631598ee3852ce9ce33fb07 (patch) | |
tree | 4b173b5657508562dfc0aa05f7d056d1e9add505 /usr/src/lib/libast/common/misc/procopen.c | |
parent | 6071ac1de68fed78e1e10052045bbb5f1732a263 (diff) | |
download | illumos-gate-7c2fbfb345896881c631598ee3852ce9ce33fb07.tar.gz |
PSARC/2008/094 ksh93 Update 1
PSARC/2008/344 ksh93 Integration Update 1 Amendments 1
PSARC/2008/589 Remove /usr/bin/printf from PSARC case 2008 094
6619428 *ksh93* RFE: Update ksh93 in Solaris to ast-ksh.2008-11-04
6788659 RFE: Update libpp in Solaris to ast-open.2008-07-25
6561901 RFE: Add "shcomp" (shell script compiler) + kernel module to exec binary sh code
6599668 RFE: Move consumers of alias.sh over to ksh93
6595183 *ksh93* RFE: Update ksh93-integration demo code
6775901 *ksh93* no C message catalogs are generated for ksh93
6451262 *sleep* RFE: /usr/bin/sleep should support floating-point values
6687139 *ksh93* command substitution, exec, and stdout redirection cause allocation loop
6703761 *ksh93* crashes in script containing uncommon output redirections
6715496 *ksh93* SEGVs on array reinitialization
6713682 *ksh93* Creating a compound variable in a subshell "bleeds through" to the calling subshell
6672350 *ksh93* causes parent shell to die when child shell is suspended
6745015 *ksh93* VARIABLE=`command substitution` assignment is not reliable on OpenSolaris
6710205 *ksh93* problem with command substitution (within back quotes) containing \$'
6737600 *ksh93* exits debugger when user presses ctrl-c
6748645 *ksh93* fc -l -e - is mis-parsed, outputs wrong error message "-e - requires single argument"
6754020 *ksh93* does weird '[' expansion
6753538 *ksh93* umask modification leaks out of a ksh93 subshell
6766246 *ksh93* bug in pattern matching
6763594 *ksh93* executes command after "command" builtin twice on failure
6762665 *ksh93* Difficult-to-reproduce SIGSEGV in ksh93
Diffstat (limited to 'usr/src/lib/libast/common/misc/procopen.c')
-rw-r--r-- | usr/src/lib/libast/common/misc/procopen.c | 64 |
1 files changed, 54 insertions, 10 deletions
diff --git a/usr/src/lib/libast/common/misc/procopen.c b/usr/src/lib/libast/common/misc/procopen.c index bdb845a671..ba026296c0 100644 --- a/usr/src/lib/libast/common/misc/procopen.c +++ b/usr/src/lib/libast/common/misc/procopen.c @@ -1,10 +1,10 @@ /*********************************************************************** * * * This software is part of the ast package * -* Copyright (c) 1985-2007 AT&T Knowledge Ventures * +* Copyright (c) 1985-2008 AT&T Intellectual Property * * and is licensed under the * * Common Public License, Version 1.0 * -* by AT&T Knowledge Ventures * +* by AT&T Intellectual Property * * * * A copy of the License is available at * * http://www.opensource.org/licenses/cpl1.0.txt * @@ -360,7 +360,7 @@ restore(Proc_t* proc) */ Proc_t* -procopen(const char* cmd, char** argv, char** envv, long* modv, long flags) +procopen(const char* cmd, char** argv, char** envv, long* modv, int flags) { register Proc_t* proc = 0; register int procfd; @@ -368,6 +368,7 @@ procopen(const char* cmd, char** argv, char** envv, long* modv, long flags) char** v; int i; int forked = 0; + int signalled = 0; long n; char path[PATH_MAX]; char env[PATH_MAX + 2]; @@ -469,10 +470,10 @@ procopen(const char* cmd, char** argv, char** envv, long* modv, long flags) sigcritical(SIG_REG_EXEC|SIG_REG_PROC); else { + signalled = 1; proc->sigint = signal(SIGINT, SIG_IGN); proc->sigquit = signal(SIGQUIT, SIG_IGN); #if defined(SIGCHLD) - proc->sigchld = signal(SIGCHLD, SIG_DFL); #if _lib_sigprocmask sigemptyset(&mask); sigaddset(&mask, SIGCHLD); @@ -481,6 +482,8 @@ procopen(const char* cmd, char** argv, char** envv, long* modv, long flags) #if _lib_sigsetmask mask = sigmask(SIGCHLD); proc->mask = sigblock(mask); +#else + proc->sigchld = signal(SIGCHLD, SIG_DFL); #endif #endif #endif @@ -491,25 +494,35 @@ procopen(const char* cmd, char** argv, char** envv, long* modv, long flags) else if (!proc->pid) { if (proc->sigint != SIG_IGN) + { proc->sigint = SIG_DFL; - signal(SIGINT, proc->sigint); + signal(SIGINT, proc->sigint); + } if (proc->sigquit != SIG_IGN) + { proc->sigquit = SIG_DFL; - signal(SIGQUIT, proc->sigquit); + signal(SIGQUIT, proc->sigquit); + } #if defined(SIGCHLD) +#if _lib_sigprocmask + sigprocmask(SIG_SETMASK, &proc->mask, NiL); +#else +#if _lib_sigsetmask + sigsetmask(proc->mask); +#else if (proc->sigchld != SIG_IGN) - proc->sigchld = SIG_DFL; - signal(SIGCHLD, proc->sigchld); + signal(SIGCHLD, SIG_DFL); +#endif +#endif #endif } - if (proc->pid == -1) + else if (proc->pid == -1) goto bad; forked = 1; } #endif if (!proc->pid) { - char* s; #if _use_spawnveg char** oenviron = 0; char* oenviron0 = 0; @@ -731,11 +744,23 @@ sfsync(sfstderr); { if (flags & PROC_FOREGROUND) { + signalled = 1; proc->sigint = signal(SIGINT, SIG_IGN); proc->sigquit = signal(SIGQUIT, SIG_IGN); #if defined(SIGCHLD) +#if _lib_sigprocmask + sigemptyset(&mask); + sigaddset(&mask, SIGCHLD); + sigprocmask(SIG_BLOCK, &mask, &proc->mask); +#else +#if _lib_sigsetmask + mask = sigmask(SIGCHLD); + proc->mask = sigblock(mask); +#else proc->sigchld = signal(SIGCHLD, SIG_DFL); #endif +#endif +#endif } } else if (modv) @@ -798,6 +823,25 @@ sfsync(sfstderr); return proc; } bad: + if (signalled) + { + if (proc->sigint != SIG_IGN) + signal(SIGINT, proc->sigint); + if (proc->sigquit != SIG_IGN) + signal(SIGQUIT, proc->sigquit); +#if defined(SIGCHLD) +#if _lib_sigprocmask + sigprocmask(SIG_SETMASK, &proc->mask, NiL); +#else +#if _lib_sigsetmask + sigsetmask(proc->mask); +#else + if (proc->sigchld != SIG_DFL) + signal(SIGCHLD, proc->sigchld); +#endif +#endif +#endif + } if ((flags & PROC_CLEANUP) && modv) for (i = 0; n = modv[i]; i++) switch (PROC_OP(n)) |