Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fsys exec stuff

  • Loading branch information...
commit da9d79183b529e5b49b5195ffc4e69f207591ad9 1 parent 494e26e
David Sugar authored May 18, 2012
2  ChangeLog
... ...
@@ -1,7 +1,7 @@
1 1
 from ucommon 5.2.2 to 5.3.0
2 2
 - sort specific string collation functions added
3 3
 - more stringpager manipulations possible
4  
-- use of stringlist_t in shell methods
  4
+- use of stringlist_t for new fsys exec.
5 5
 - string inpuit and output for bufpager.
6 6
 
7 7
 from ucommon 5.2.1 to 5.2.2
16  corelib/fsys.cpp
@@ -24,6 +24,8 @@
24 24
 #include <ucommon/thread.h>
25 25
 #include <ucommon/fsys.h>
26 26
 #include <ucommon/string.h>
  27
+#include <ucommon/memory.h>
  28
+#include <ucommon/shell.h>
27 29
 
28 30
 #ifdef  HAVE_SYSLOG_H
29 31
 #include <syslog.h>
@@ -1554,3 +1556,17 @@ fd_t fsys::release(void)
1554 1556
     error = 0;
1555 1557
     return save;
1556 1558
 }
  1559
+
  1560
+int fsys::exec(const char *path, char **argv)
  1561
+{
  1562
+    shell::pid_t pid = shell::spawn(path, argv);
  1563
+    return shell::wait(pid);
  1564
+}
  1565
+
  1566
+int fsys::exec(const char *path, stringlist_t& list)
  1567
+{
  1568
+    char **argv = stringpager::index(list);
  1569
+    shell::pid_t pid = shell::spawn(path, argv);
  1570
+    stringpager::release(argv);
  1571
+    return shell::wait(pid);
  1572
+}
15  corelib/shell.cpp
@@ -2911,18 +2911,3 @@ String shell::path(path_t id, const char *dir)
2911 2911
     return result;
2912 2912
 }
2913 2913
 
2914  
-shell::pid_t shell::spawn(const char *path, stringlist_t& list, char **envp, fd_t *stdio)
2915  
-{
2916  
-    char **argv = stringpager::index(list);
2917  
-    pid_t pid = spawn(path, argv, envp, stdio);
2918  
-    stringpager::release(argv);
2919  
-    return pid;
2920  
-}
2921  
-
2922  
-shell::pipe_t shell::spawn(const char *path, stringlist_t& list, pmode_t mode, size_t size, char **env)
2923  
-{
2924  
-    char **argv = stringpager::index(list);
2925  
-    pipe_t pio = spawn(path, argv, mode, size, env);
2926  
-    stringpager::release(argv);
2927  
-    return pio;
2928  
-}
20  inc/ucommon/fsys.h
@@ -43,6 +43,10 @@
43 43
 #include <ucommon/string.h>
44 44
 #endif
45 45
 
  46
+#ifndef _UCOMMON_MEMORY_H_
  47
+#include <ucommon/memory.h>
  48
+#endif
  49
+
46 50
 #ifndef _MSWINDOWS_
47 51
 #include <sys/stat.h>
48 52
 #else
@@ -607,6 +611,22 @@ class __EXPORT fsys
607 611
     static int load(const char *path);
608 612
 
609 613
     /**
  614
+     * Execute a process and get exit code.
  615
+     * @param path to execute.
  616
+     * @param argv list.
  617
+     * @return exit code.
  618
+     */
  619
+    static int exec(const char *path, char **argv);
  620
+
  621
+    /**
  622
+     * Execute a process and get exit code.
  623
+     * @param path to execute.
  624
+     * @param argv list.
  625
+     * @return exit code.
  626
+     */
  627
+    static int exec(const char *path, stringlist_t& argv);
  628
+
  629
+    /**
610 630
      * Load a plugin into memory.
611 631
      * @param module for management.
612 632
      * @param path to plugin.
4  inc/ucommon/shell.h
@@ -906,8 +906,6 @@ class __EXPORT shell : public mempager
906 906
      */
907 907
     static shell::pid_t spawn(const char *path, char **argv, char **env = NULL, fd_t *stdio = NULL);
908 908
 
909  
-    static shell::pid_t spawn(const char *path, stringlist_t& argv, char **env = NULL, fd_t *stdio = NULL);
910  
-
911 909
     /**
912 910
      * Spawn a child pipe.  If the executable path is a pure filename, then
913 911
      * the $PATH will be used to find it.  The argv array may be created from
@@ -921,8 +919,6 @@ class __EXPORT shell : public mempager
921 919
      */
922 920
     static shell::pipe_t spawn(const char *path, char **argv, pmode_t mode, size_t size = 512, char **env = NULL);
923 921
 
924  
-    static shell::pipe_t spawn(const char *path, stringlist_t& argv, pmode_t mode, size_t size = 512, char **env = NULL);
925  
-
926 922
     /**
927 923
      * Set priority level and enable priority scheduler.  This activates the
928 924
      * realtime priority scheduler when a priority > 0 is requested for the

0 notes on commit da9d791

Please sign in to comment.
Something went wrong with that request. Please try again.