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

execs, execsp, execspe - execute a file taking its arguments from a string

Author

       Renzo Davoli <renzo@cs.unibo.it>

VirtualSquare                                      2014-05-27                                           execs(3)

Bugs

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

Description

       This group of functions extends the family of exec(3) provided by the libc.
       execs,  execse,  execsp  and  execspe  are  similar  to  execv(3),  execve(2),  execvp(3) and execvpe(3),
       respectively, but take the command line arguments for the file to execute (and the also the command  name
       for execsp(3) and execspe(3)) by parsing a command string args.
       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.
       execs,  execse,  execsp and execspe do not use dynamic allocation but require space on the stack to store
       an entire copy of args.  eexecs, eexecse, eexecsp and eexecspe do not use extra stack  space  but  modify
       args.

       In case the same argv should be used for several exec command, use s2argv(3) to parse the args just once.

Example

       The following program demonstrates the use of execs:

       #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");
            if (fgets(buf, BUFLEN, stdin) != NULL) {
                 execsp(buf);
                 printf("exec error\n");
            }
       }

Name

       execs, execsp, execspe - execute a file taking its arguments from a string

Return Value

       These  functions  return  only if an error has occurred. The return value is always -1. The failure cases
       and errno values are those specified for execve(2).

See Also

exec(3),s2argv(3)

Synopsis

#include<unistd.h>#include<execs.h>intexecs(constchar*path,constchar*args);intexecse(constchar*path,constchar*args,char*constenvp[]);intexecsp(constchar*args);intexecspe(constchar*args,char*constenvp[]);inteexecs(constchar*path,char*args);inteexecse(constchar*path,char*args,char*constenvp[]);inteexecsp(char*args);inteexecspe(char*args,char*constenvp[]);

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

See Also