pike.git / lib / modules / Process.pmod

version» Context lines:

pike.git/lib/modules/Process.pmod:451:   //! Optional launcher prefix command used to spawn the pike binary.   //!   //! When used this is typically something like   //! @expr{({ "/usr/bin/valgrind" })@}.   //!   //! Defaults to the empty array.   //!   //! @seealso   //! @[Process.Process]   Process spawn_pike(array(string) argv, void|mapping(string:mixed) options, -  array(string)|void launcher) +  array(string) launcher = ({}))   {    if (!runpike) {    array(string) res = ({    master()->_pike_file_name,    });    if (master()->_master_file_name)    res+=({"-m"+master()->_master_file_name});    foreach (master()->pike_module_path;;string path)    res+=({"-M" + path});    if(options && options->add_predefines)
pike.git/lib/modules/Process.pmod:488:    }       if (sizeof(res) && !has_value(res[0],"/")   #ifdef __NT__    && !has_value(res[0], "\\")   #endif /* __NT__ */    )    res[0] = search_path(res[0]);    runpike = res;    } -  if (!launcher) launcher = ({}); +     return Process(launcher + runpike + argv, options);   }      //! Easy and lazy way of using @[Process.Process] that runs a process   //! and returns a mapping with the output and exit code without   //! having to make sure you read nonblocking yourself.   //!   //! @param args   //! Either a command line array, as the command_args   //! argument to @[create_process()], or a string that
pike.git/lib/modules/Process.pmod:538:   //! returned mapping it could potentially grow until memory runs out.   //! It is therefore advisable to set up rlimits if the output has a   //! potential to be very large, or else provide functions to handle   //! partial data.   //!   //! @example   //! Process.run( ({ "ls", "-l" }) );   //! Process.run( ({ "ls", "-l" }), ([ "cwd":"/etc" ]) );   //! Process.run( "ls -l" );   //! Process.run( "awk -F: '{print $2}'", ([ "stdin":"foo:2\nbar:17\n" ]) ); - mapping run(string|array(string) cmd, void|mapping modifiers) + mapping run(string|array(string) cmd, mapping modifiers = ([]))   {    string gotstdout="", gotstderr="", stdin_str;    int exitcode;    -  if(!modifiers) -  modifiers = ([]); -  +     if((modifiers->stdout && !callablep(modifiers->stdout))    || (modifiers->stderr && !callablep(modifiers->stderr)))    throw( ({ "Can not redirect stdout or stderr in Process.run, "    "please use Process.Process instead.", backtrace() }) );       object(Stdio.File)|zero mystdout = Stdio.File();    object(Stdio.File)|zero mystderr = Stdio.File();    object(Stdio.File)|zero mystdin;       object|zero p;
pike.git/lib/modules/Process.pmod:1027: Inside #if undefined(__NT__) and #if constant(fork) && constant(exece)
  {    object stdin;    object stdout;    object stderr;    array(object) fd;       object pid;       private object low_spawn(array(Stdio.File) fdp,    array(Stdio.File) fd_to_close, -  string cmd, void|array(string) args, +  string cmd, void|array(string) args=({}),    void|mapping(string:string) env,    string|void cwd)    {    Stdio.File pie, pied; // interprocess communication    object pid;       pie=Stdio.File();    pied=pie->pipe();       if(!(pid=fork()))
pike.git/lib/modules/Process.pmod:1059: Inside #if undefined(__NT__) and #if constant(fork) && constant(exece)
   if (sizeof(fdp)>2 && fdp[2]) fdp[2]->dup2(Stdio.File("stderr"));    /* dup2 fdd[3..] here FIXME FIXME */    foreach (fd_to_close, Stdio.File f)    if (objectp(f)) { f->close(); destruct(f); }    pie->close();    destruct(pie);       pied->set_close_on_exec(1);       if (env) -  exece(cmd,args||({}),env); +  exece(cmd,args,env);    else -  exece(cmd,args||({})); +  exece(cmd,args);       error( "pike: failed to exece %O: %s.\n", cmd,    strerror(errno()) );    };       pied->write(encode_value(err));    exit(1);    }       foreach (fdp,object f) if (objectp(f)) { f->close(); destruct(f); }