Process API

API Reference


This API provides a means to spawn external processes. The function le_proc_Execute() takes a structure which is populated with the execution parameters and handles the heavy lifting of (on Linux) forking and execing as necessary.

int status;
{
.executableStr = "/bin/ls",
.argumentsPtr = { "/bin/ls", "/tmp", NULL },
.environmentPtr = NULL,
.detach = false,
.closeFds = LE_PROC_NO_FDS,
.init = NULL,
.userPtr = NULL
};
 
pid_t pid = le_proc_Execute(&proc);
if (pid < 0)
{
LE_FATAL("Oh no! Something went wrong (error %d).", errno);
}
if (waitpid(pid, &status, 0) > 0)
{
LE_INFO("%s[%d] returned %d", proc.executableStr, (int) pid, status);
}