pike.git / lib / modules / Process.pmod

version» Context lines:

pike.git/lib/modules/Process.pmod:110:    //! Based on @[create_process].    inherit create_process;       protected function(Process:void) read_cb;    protected function(Process:void) timeout_cb;       protected Stdio.File process_fd;       protected Pike.Backend process_backend;    +  protected mixed process_poll; +     //! @param command_args    //! Either a command line array, as the command_args    //! argument to @[create_process()], or a string that    //! will be splitted into a command line array by    //! calling @[split_quoted_string()] in an operating    //! system dependant mode.    //! @param modifiers    //! In addition to the modifiers that @[create_process] accepts,    //! this object also accepts    //! @mapping
pike.git/lib/modules/Process.pmod:217: Inside #if constant(Stdio.__HAVE_SEND_FD__)
   bytes, sizeof(data));    }    process_backend = Pike.SmallBackend();    process_backend->add_file(process_fd);    process_fd->set_nonblocking(got_data, UNDEFINED, got_close);       // Wait for the process to fork (or fail).    while (__status == -1) {    process_backend(3600.0);    } +  +  if (process_fd) { +  process_poll = call_out(do_poll_loop, 0.1); +  }    } else   #endif    {    ::create( [array(string)]command_args, new_modifiers );    }       if (modifiers) {    if(read_cb = modifiers->read_callback)    call_out(watcher, 0.1);   
pike.git/lib/modules/Process.pmod:242: Inside #if constant(Stdio.__HAVE_SEND_FD__)
     #if constant(Stdio.__HAVE_SEND_FD__)    protected void do_close()    {    if (process_fd) {    process_fd->set_blocking();    process_fd->close();    }    process_fd = UNDEFINED;    process_backend = UNDEFINED; +  remove_call_out(process_poll);    }       protected string recv_buf = "";    protected void got_data(mixed ignored, string data)    {    recv_buf += data;    while (sizeof(recv_buf) > 3) {    while (has_prefix(recv_buf, "\0\0\0\0")) recv_buf = recv_buf[4..];    if (sizeof(recv_buf) < 5) return;    int len = 0;
pike.git/lib/modules/Process.pmod:307: Inside #if constant(Stdio.__HAVE_SEND_FD__)
   protected void got_close(mixed ignored)    {    do_close();    if (__status == -1) {    // Early close.    __result = 255;    __status = 2;    }    }    +  protected void do_poll(float t) +  { +  mixed err = catch { +  process_backend && process_backend(t); +  return; +  }; +  // Filter errors about the backend already running. +  if (arrayp(err) && sizeof(err) && +  stringp(err[0]) && has_prefix(err[0], "Backend already ")) return; +  throw(err); +  } +  +  protected void do_poll_loop() +  { +  process_poll = UNDEFINED; +  if (!process_backend) return; +  do_poll(0.0); +  process_poll = call_out(do_poll_loop, 0.1); +  } +     int last_signal()    { -  process_backend && process_backend(0.0); +  do_poll(0.0);    return ::last_signal();    }       int(-1..2) status()    { -  process_backend && process_backend(0.0); +  do_poll(0.0);    return ::status();    }       int wait()    {    if (process_backend) { -  process_backend(0.0); +  do_poll(0.0);    while (__status <= 0) { -  process_backend(3600.0); +  do_poll(3600.0);    }    return __result;    }    return ::wait();    }   #endif /* __HAVE_SEND_FD__ */       protected void destroy() {    remove_call_out(watcher);    remove_call_out(killer); -  + #if constant(Stdio.__HAVE_SEND_FD__) +  remove_call_out(process_poll); + #endif    }       protected void watcher() {    // It was another sigchld, but not one from our process.    if(status()==0)    call_out(watcher, 0.1);    else {    remove_call_out(killer);    if(read_cb) read_cb(this);    }