pike.git / lib / modules / Process.pmod

version» Context lines:

pike.git/lib/modules/Process.pmod:13:   {    inherit __builtin.create_process;       //! @param 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].    //! @seealso    //! @[create_process], @[split_quoted_string] -  void create( string|array(string) args, void|mapping m ) +  void create( string|array(string) args, void|mapping(string:mixed) m )    {    if( stringp( args ) ) -  args = split_quoted_string( args ); +  args = split_quoted_string( [string]args );    if( m ) -  ::create( args, m ); +  ::create( [array(string)]args, m );    else -  ::create( args ); +  ::create( [array(string)]args );    }   }      //!   int exec(string file,string ... foo)   {    if (sizeof(file)) {    string path;       if(has_value(file,"/")) -  return exece(combine_path(getcwd(),file),foo,getenv()); +  return exece(combine_path(getcwd(),file),foo, +  [mapping(string:string)]getenv());    -  path=getenv("PATH"); +  path=[string]getenv("PATH");       foreach(path ? path/":" : ({}) , path)    if(file_stat(path=combine_path(path,file))) -  return exece(path, foo,getenv()); +  return exece(path, foo, [mapping(string:string)]getenv());    }    return 69;   }      static array(string) search_path_entries=0;      //!   string search_path(string command)   {    if (command=="" || command[0]=='/') return command;
pike.git/lib/modules/Process.pmod:60:    {    array(string) e=(getenv("PATH")||"")/":"-({""});       multiset(string) filter=(<>);    search_path_entries=({});    foreach (e,string s)    {    string t;    if (s[0]=='~') // some shells allow ~-expansion in PATH    { -  if (s[0..1]=="~/" && (t=getenv("HOME"))) +  if (s[0..1]=="~/" && (t=[string]getenv("HOME")))    s=t+s[1..];    else    {    // expand user?    }    }    if (!filter[s] /* && directory exist */ )    {    search_path_entries+=({s});    filter[s]=1;
pike.git/lib/modules/Process.pmod:160:    break;    }    }    return ret;   }      //!   Process spawn(string s,object|void stdin,object|void stdout,object|void stderr,    function|void cleanup, mixed ... args)   { -  mapping data=(["env":getenv()]); +  mapping(string:mixed) data=(["env":getenv()]);    if(stdin) data->stdin=stdin;    if(stdout) data->stdout=stdout;    if(stderr) data->stderr=stderr;   #if defined(__NT__)    // if the command string s is not quoted, add double quotes to    // make sure it is not modified by create_process    if (sizeof(s) <= 1 || s[0] != '\"' || s[sizeof(s)-1] != '\"')    s = "\"" + s + "\"";    return create_process(({ "cmd", "/c", s }),data);   #elif defined(__amigaos__)    return create_process(split_quoted_string(s),data);   #else /* !__NT__||__amigaos__ */    return create_process(({ "/bin/sh", "-c", s }),data);   #endif /* __NT__||__amigaos__ */      }      //!   string popen(string s)   { -  object p; -  string t; -  object f = Stdio.File(); +  Stdio.File f = Stdio.File();       if (!f) error("Popen failed. (couldn't create pipe)\n");    -  p=f->pipe(Stdio.PROP_IPC); +  Stdio.File p=f->pipe(Stdio.PROP_IPC);    if(!p) error("Popen failed. (couldn't create pipe)\n");    spawn(s,0,p,0, destruct, f);    p->close();    destruct(p);    -  t=f->read(0x7fffffff); +  string t=f->read(0x7fffffff);    if(!t)    {    int e;    e=f->errno();    f->close();    destruct(f);    error("Popen failed with error "+e+".\n");    } else {    f->close();    destruct(f);
pike.git/lib/modules/Process.pmod:235: Inside #if undefined(__NT__) and #if constant(fork)
  //!   class Spawn   {    object stdin;    object stdout;    object stderr;    array(object) fd;       object pid;    -  private object low_spawn(array(void|object(Stdio.File)) fdp, -  array(void|object(Stdio.File)) fd_to_close, +  private object low_spawn(array(Stdio.File) fdp, +  array(Stdio.File) fd_to_close,    string cmd, void|array(string) args,    void|mapping(string:string) env,    string|void cwd)    { -  object(Stdio.File) pie,pied; /* interprocess communication */ +  Stdio.File pie, pied; // interprocess communication    object pid;       pie=Stdio.File();    pied=pie->pipe();       if(!(pid=fork()))    {    mixed err=catch    {    if(cwd && !cd(cwd))    {    error( "pike: cannot change cwd to "+cwd+    ": "+strerror(errno())+"\n" );    }       if (sizeof(fdp)>0 && fdp[0]) fdp[0]->dup2(Stdio.File("stdin"));    if (sizeof(fdp)>1 && fdp[1]) fdp[1]->dup2(Stdio.File("stdout"));    if (sizeof(fdp)>2 && fdp[2]) fdp[2]->dup2(Stdio.File("stderr"));    /* dup2 fdd[3..] here FIXME FIXME */ -  foreach (fd_to_close,object f) +  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);    else    exece(cmd,args||({}));