pike.git / lib / modules / Process.pmod

version» Context lines:

pike.git/lib/modules/Process.pmod:12:       path=getenv("PATH");       foreach((path?(path/":"):({})),path)    if(file_stat(path=combine_path(path,file)))    return exece(path, foo,getenv());       return 69;   }    - varargs int spawn(string s,object stdin,object stdout,object stderr) + varargs object spawn(string s,object stdin,object stdout,object stderr)   { -  int pid; -  -  pid=fork(); -  -  if(pid==-1) -  error("No more processes.\n"); -  -  if(pid) +  if(object proc=fork())    { -  return pid; +  return proc;    }else{    if(stdin) {    stdin->dup2(File("stdin"));    stdin->close();    }       if(stdout) {    stdout->dup2(File("stdout"));    stdout->close();    }
pike.git/lib/modules/Process.pmod:56:   {    object p;    string t;       p=file::pipe();    if(!p) error("Popen failed. (couldn't create pipe)\n");    spawn(s,0,p,0);    p->close();    destruct(p);    -  t=read(0x7fffffff); +  t=read();    if(!t)    {    int e;    e=errno();    close();    error("Popen failed with error "+e+".\n");    }else{    close();    }    return t;   }    - void system(string s) - { -  object p; -  int pid; -  string t; + int system(string s) { return spawn(s)->wait(); }    -  p=file::pipe(); -  if(!p) error("System() failed.\n"); -  p->set_close_on_exec(0); -  if(pid=fork()) -  { -  destruct(p); -  /* Nothing will ever be written here, we are just waiting for it -  * to close -  */ -  file::read(1); -  }else{ -  exec("/bin/sh","-c",s); -  exit(69); -  } - } -  +    constant fork = predef::fork;   constant exece = predef::exece;