logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

esystem, system_eexecsp - execute a command with its arguments from a string without using a shell

Author

       Renzo Davoli <renzo@cs.unibo.it>

VirtualSquare                                      2014-05-27                                     system_nosh(3)

Bugs

       Bug reports should be addressed to <info@virtualsquare.org>

Description

esystem  is  an almost drop in replacement for system(3) provided by the libc. esystem parses the command
       string and runs the command directly, without using a shell.  (system_eexecsp and esystem are synonyms).
       Command arguments in args are delimited by space characters (blank, tabs or new lines).  Single or double
       quotes can be used to delimitate command arguments including spaces and a non quoted backslash (\) is the
       escape character to protect the next char. The executable file  is  sought  using  the  PATH  environment
       variable as explained for execlp(3).

Example

       The following program shows the usage of esystem:

       #include <stdio.h>
       #include <unistd.h>
       #include <execs.h>

       #define BUFLEN 1024
       int main(int argc, char *argv)
       {
            char buf[BUFLEN];
            printf("type in a command and its arguments, e.g. 'ls -l'\n");
            while (fgets(buf, BUFLEN, stdin) != NULL) {
                 printf("Command: '%s' \n",buf);
                 esystem(buf);
                 printf("Command done\n");
            }
       }

Name

       esystem, system_eexecsp - execute a command with its arguments from a string without using a shell

Return Value

       These functions have the same return values of system(3).

See Also

system(3),execs(3),s2argv(3),system_nosh(3)

Synopsis

#include<stdlib.h>#include<execs.h>intesystem(constchar*command);intsystem_eexecsp(constchar*command);

       These functions are provided by libexecs and libeexecs. Link with -lexecs or -leexecs.

See Also