home *** CD-ROM | disk | FTP | other *** search
- From: peter@ficc.uu.net (Peter da Silva)
- Newsgroups: alt.sources
- Subject: Patch for TCL for systems without dup2.
- Message-ID: <O762Y24ggpc2@ficc.uu.net>
- Date: 12 Mar 90 04:51:34 GMT
-
- Archive-name: tcl/patch.1
-
- Here's a patch for tcl for older System V systems without the dup2 system
- call (or library routine). It's a bit overkillish, but makes the code a bit
- nicer. Rather than emulate dup2, I switched back to the older method of
- depending on fds being allocated in numerical order...
-
- *** tclCmdAH.old
- --- tclCmdAH.c
- ***************
- *** 410,415 ****
- --- 410,435 ----
- *----------------------------------------------------------------------
- */
-
- + static int setup_fds(fd0, fd1, fd2)
- + {
- + if(fd0 != -1) {
- + close(0);
- + if(dup(fd0) != 0)
- + return 0;
- + }
- + if(fd1 != -1) {
- + close(1);
- + if(dup(fd1) != 1)
- + return 0;
- + }
- + if(fd2 != -1) {
- + close(2);
- + if(dup(fd2) != 2)
- + return 0;
- + }
- + return 1;
- + }
- +
- /* ARGSUSED */
- int
- Tcl_ExecCmd(dummy, interp, argc, argv)
- ***************
- *** 510,517 ****
- if (pid == 0) {
- char errSpace[100];
-
- ! if (( (stdIn != -1) && (dup2(stdIn, 0) == -1) )
- ! || (dup2(stdOut[1], 1) == -1) || (dup2(stdOut[1], 2) == -1)) {
- char *err;
- err = "forked process couldn't set up input/output";
- write(stdOut[1], err, strlen(err));
- --- 530,536 ----
- if (pid == 0) {
- char errSpace[100];
-
- ! if(!setup_fds(stdIn, stdOut[1], stdOut[1])) {
- char *err;
- err = "forked process couldn't set up input/output";
- write(stdOut[1], err, strlen(err));
- --
- _--_|\ `-_-' Peter da Silva. +1 713 274 5180. <peter@ficc.uu.net>.
- / \ 'U`
- \_.--._/
- v
-