From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from plg.uwaterloo.ca ([129.97.140.10]) by hawkwind.utcs.utoronto.ca with SMTP id <24036>; Fri, 8 Jul 1994 15:24:02 -0400 Received: by plg.uwaterloo.ca id <185321>; Fri, 8 Jul 1994 15:23:51 -0400 From: Dave Mason To: rc@hawkwind.utcs.toronto.edu Subject: rc as a login shell, and Solaris X-Face: %Q_F^9R-:'3MM7eZ6@E.x@f\*bgatzGv-8d%I~L[p^.F)3QF{kq\UTsu|e#?)3FPwJNvPPB !s*He|-*M^p*~bh"Nywm5NLL\\Rl3r(hWHY*F:$/RdKV*bS";n&#\Ov@*=]mu\}6tP Date: Fri, 8 Jul 1994 15:23:42 -0400 I have been using rc as my (virtual) login shell for several years, however I actually had itcsh in /etc/passwd because it has a feature where it will pass the -c string to the shell.... I took that string and exec'd rc to do the real work. Well we've moved to Solaris and itcsh (apparently) doesn't work, so I was forced to change. So what I did was added 2 lines to main.c that make -c imply -l, so I get a chance to set environments, etc. before executing the command, and put the -c string into the variable ``Command''. Then the start of my .rcrc says: ------ home=`/bin/pwd # get *real* home directory name (less symbolic links) if (! ~ $#Command 0) { ~ $#prepath 0 && { . ./.rc/rcmin fn prompt { reenv;refn ~ $TERM emacs && prompt = ('; ' '') && history=() && PAGER=cat fn prompt }} eval `` () {echo 'fn _C_ {'^$Command'}'|sed -e 's/(/{/g' -e 's/)/}/g'} Command= () _C_ exit } ------ The cost of this is that anything that does a ``rc -c ....'' incurs the overhead of rc opening .rcrc, but this seems pretty insignificant, given the resulting flexibility. As in my example above, initialization cost can be minimized to this level by such things as checking if ``prepath'' is already set. The remaining patches were required to make everything work properly on solaris. The only significant problem was that SIGCHLD when set to SIG_IGN causes exiting processes to *not* return their pid's to wait(2)! Because of a bug in wait.c, this caused rc to loop when run directly from rshd (which sets SIGCHLD to SIG_IGN). There is a patch to signal.c to always force SIGCHLD to SIG_IGN (conditionalized on NOSIGCLDIGN) and a patch to wait.c to fix the behaviour. The remaining patches simply get protypes to match the system ones. This now works very nicely. ../Dave *** rc-1.4/main.c Sun May 24 16:39:04 1992 --- rc-1.4-dvm/main.c Fri Jul 8 13:34:47 1994 *************** *** 40,45 **** --- 40,48 ---- dashdee = TRUE; break; case 'c': + #ifdef DASHC + dashell = TRUE; + #endif dashsee[0] = rc_optarg; goto quitopts; case 'n': *************** *** 79,84 **** --- 82,90 ---- starassign(dollarzero, null, FALSE); /* assign $0 to $* */ inithandler(); if (dashsee[0] != NULL) { /* input from the -c flag? */ + #ifdef DASHC + assigndefault("Command", dashsee[0], (void *)0); + #endif if (*argv != NULL) starassign(dollarzero, argv, FALSE); pushstring(dashsee, TRUE); *** rc-1.4/signal.c Wed Apr 15 16:47:00 1992 --- rc-1.4-dvm/signal.c Fri Jul 8 13:33:55 1994 *************** *** 69,74 **** --- 69,79 ---- int i; for (i = 1; i < NUMOFSIGNALS; i++) { if ((h = signal(i, SIG_DFL)) != SIG_DFL) + #ifdef NOSIGCLDIGN + if (i==SIGCHLD && h==SIG_IGN) + h=SIG_DFL; + else + #endif signal(i, h); sighandlers[i] = h; } *** rc-1.4/wait.c Fri Apr 17 19:26:25 1992 --- rc-1.4-dvm/wait.c Fri Jul 8 13:35:11 1994 *************** *** 53,59 **** while (pid != (ret = rc_wait(stat))) { Pid *q; if (ret < 0) { ! if (nointr) goto again; return ret; } --- 53,59 ---- while (pid != (ret = rc_wait(stat))) { Pid *q; if (ret < 0) { ! if (nointr && errno==EINTR) goto again; return ret; } *** rc-1.4/builtins.c Tue May 26 00:42:58 1992 --- rc-1.4-dvm/builtins.c Thu Jul 7 15:09:55 1994 *************** *** 441,447 **** }; extern int getrlimit(int, struct rlimit *); ! extern int setrlimit(int, struct rlimit *); static void printlimit(const Limit *limit, bool hard) { struct rlimit rlim; --- 441,447 ---- }; extern int getrlimit(int, struct rlimit *); ! extern int setrlimit(int, const struct rlimit *); static void printlimit(const Limit *limit, bool hard) { struct rlimit rlim; *** rc-1.4/config.h Fri Sep 11 22:56:16 1992 --- rc-1.4-dvm/config.h Fri Jul 8 15:18:12 1994 *************** *** 25,30 **** --- 25,37 ---- */ /* + * Define the macro DASHC if you want the -c string put into the + * environment variable Command and to force -l so that the .rcrc file + * can control the environment for the command execution. + #define DASHC + */ + + /* * Define the macro SVSIGS if your system has System V signal semantics, * i.e., if "slow" system calls are interrupted rather than resumed * after returning from an interrupt handler. (If you are not sure what *************** *** 64,69 **** --- 71,83 ---- */ /* + * Define the macro NOSIGCLDIGN if your system uses SIGCLD set to SIG_IGN + * to mean that it should reap child processes as they exit. This probably + * only matters if you use rc as your login shell and want rsh to work. + #define NOSIGCLDIGN + */ + + /* * Define the macro READLINE if you want rc to call GNU readline * instead of read(2) on interactive shells. #define READLINE *************** *** 108,113 **** --- 122,132 ---- #define NOJOB */ + /* + * Define the macro SYSVR4 if your system has System V include prototypes + #define SYSVR4 + */ + /* Beginning of defaults section: */ #ifndef CUSTOM *************** *** 131,139 **** --- 150,168 ---- #endif #ifdef sun /* Used on SunOS 4.1.1 */ + #ifdef __svr4__ + #define SVSIGS + #define NOSIGCLD + #define NOSIGCLDIGN + #define SYSVR4 #define PROTECT_ENV #undef DEFAULTPATH + #define DEFAULTPATH "/usr/bin", "/bin", "." + #else + #define PROTECT_ENV + #undef DEFAULTPATH #define DEFAULTPATH "/usr/ucb", "/usr/bin", "." + #endif #endif /*