~ubuntu-branches/ubuntu/wily/picolisp/wily-proposed

« back to all changes in this revision

Viewing changes to src/io.c

  • Committer: Package Import Robot
  • Author(s): Kan-Ru Chen (陳侃如)
  • Date: 2015-02-06 00:19:20 UTC
  • mfrom: (1.2.2)
  • Revision ID: package-import@ubuntu.com-20150206001920-ug3fakmqpq9apw5o
Tags: 3.1.9.7-1
* New upstream release
* Build *.jar from source
* Do not install doc/{db,utf8} as requested by upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* 16dec14abu
 
1
/* 30jan15abu
2
2
 * (c) Software Lab. Alexander Burger
3
3
 */
4
4
 
2177
2177
   } f;
2178
2178
   int pfd[2];
2179
2179
 
2180
 
   if (pipe(pfd) < 0)
 
2180
   if ((isCell(cddr(ex))? pipe(pfd) : socketpair(AF_UNIX, SOCK_STREAM, 0, pfd)) < 0  ||  pfd[1] < 2)
2181
2181
      err(ex, NULL, "Can't pipe");
2182
2182
   closeOnExec(ex, pfd[0]), closeOnExec(ex, pfd[1]);
2183
2183
   if ((f.in.pid = forkLisp(ex)) == 0) {
 
2184
      close(pfd[0]);
2184
2185
      if (isCell(cddr(ex)))
2185
2186
         setpgid(0,0);
2186
 
      close(pfd[0]);
2187
 
      if (pfd[1] != STDOUT_FILENO)
2188
 
         dup2(pfd[1], STDOUT_FILENO),  close(pfd[1]);
2189
 
      wrOpen(ex, Nil, &f.out);
 
2187
      else
 
2188
         dup2(pfd[1], STDIN_FILENO);
 
2189
      dup2(pfd[1], STDOUT_FILENO);
 
2190
      close(pfd[1]);
 
2191
      signal(SIGPIPE, SIG_DFL);
 
2192
      f.out.pid = 0,  f.out.fd = STDOUT_FILENO;
2190
2193
      pushOutFiles(&f.out);
2191
2194
      OutFile->tty = NO;
2192
 
      val(Run) = Nil;
 
2195
      val(Led) = val(Run) = Nil;
2193
2196
      EVAL(cadr(ex));
2194
2197
      bye(0);
2195
2198
   }
2196
2199
   close(pfd[1]);
2197
2200
   initInFile(f.in.fd = pfd[0], NULL);
2198
 
   if (!isCell(cddr(ex)))
 
2201
   if (!isCell(cddr(ex))) {
 
2202
      initOutFile(pfd[0]);
2199
2203
      return boxCnt(pfd[0]);
 
2204
   }
2200
2205
   setpgid(f.in.pid,0);
2201
2206
   pushInFiles(&f.in);
2202
2207
   x = prog(cddr(ex));