Sumanth Naropanth wrote: [CC:'ing shell-discuss at opensolaris.org (please make sure to keep this list in the CC:)] > Jeffrey Hutzelman wrote on 10/31/08 14:29: > > I'd also consider whether you want an interface like that of execve(), > > which takes a char ** rather than a variable number of char * arguments, > > and/or a variant that accepts a single va_list instead of a variable > > number of arguments, to make it easier to write wrappers. > > I am considering this in my revised proposal.
What about the following API: Prototype: |int exec_system(const char *commandargs, const char **envp, uint32_t flags, int *child_returncode, ...);| Arguments would be: |commandargs| would be a chain of C strings (each terminated with a '\0' byte) which is itself terminated by a '\0'-byte. For example if you want to execute the shell equivalent of $ ls -l /etc/profile # you set the string to: "/usr/bin/ls\0-l\0/etc/profile\0\0" ('\0' represents a '\0'-byte, not that the string is passed though |sprintf()| or something similar!) The use of '\0' as argument delimiter should solve the various problems described in the reply to the original proposal while keeping the API simple. |envp| points to an optional array of C strings representing the child process's environment variables. If the pointer is |NULL| the parents environment is used. |child_returncode| points to the child process's return code (this is seperated here to avoid the mess of dismanteling the value via macros etc.). The pointer may be |NULL| |flags| is a flag to modify the behaviour of the function on demand (e.g. for future usage). For example we may add a |EXEC_SYSTEM_MERGE_ENVP| which defines that the array suppiled by |envp| is combined with the current environment (instead of replacing it completely). |...| allows to define more arguments in the future if matching bits in |flags| are set ---- Bye, Roland -- __ . . __ (o.\ \/ /.o) roland.mainz at nrubsig.org \__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer /O /==\ O\ TEL +49 641 3992797 (;O/ \/ \O;)