Linux repositories inspector

execs(3)

VirtualSquare
2014-05-27
Aliases: eexecs(3), eexecse(3), eexecsp(3), eexecspe(3), execse(3), execsp(3), execspe(3)

libexecs-dev

C library for commands execution - development files

NAME

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

SYNOPSIS

#include <unistd.h>
#include <execs.h>
int execs(const char *path, const char *args);
int execse(const char *path, const char *args, char *const envp[]);
int execsp(const char *args);
int execspe(const char *args, char *const envp[]);
int eexecs(const char *path, char *args);
int eexecse(const char *path, char *args, char *const envp[]);
int eexecsp(char *args);
int eexecspe(char *args, char *const envp[]);
These functions are provided by libexecs and libeexecs. Link with -lexecs or -leexecs.

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.

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).

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"); } }

BUGS

Bug reports should be addressed to <>

AUTHOR

Renzo Davoli <>
⇧ Top