Adding lam_few(), A function which forks, exec's and waits
This commit was SVN r223.
Этот коммит содержится в:
родитель
ba4bdca6dd
Коммит
3dc60f27a2
@ -11,6 +11,7 @@ noinst_LTLIBRARIES = libutil.la
|
|||||||
|
|
||||||
headers = \
|
headers = \
|
||||||
argv.h \
|
argv.h \
|
||||||
|
few.h \
|
||||||
lam_log.h \
|
lam_log.h \
|
||||||
malloc.h \
|
malloc.h \
|
||||||
path.h \
|
path.h \
|
||||||
@ -20,6 +21,7 @@ headers = \
|
|||||||
libutil_la_SOURCES = \
|
libutil_la_SOURCES = \
|
||||||
$(headers) \
|
$(headers) \
|
||||||
argv.c \
|
argv.c \
|
||||||
|
few.c \
|
||||||
lam_log.c \
|
lam_log.c \
|
||||||
path.c \
|
path.c \
|
||||||
reactor.c \
|
reactor.c \
|
||||||
|
45
src/lam/util/few.c
Обычный файл
45
src/lam/util/few.c
Обычный файл
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* $HEADER$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "lam_config.h"
|
||||||
|
#include "lam/util/few.h"
|
||||||
|
|
||||||
|
/** @file **/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* forks, execs and waits for a subordinate program
|
||||||
|
*
|
||||||
|
* @param argv Argument vector, argv[0] is the program
|
||||||
|
* @retval Status code or ERROR
|
||||||
|
* Returns: - status code or ERROR
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
lam_few(char *argv[])
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
int pid;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if ((pid = fork()) < 0) {
|
||||||
|
return(pid);
|
||||||
|
}
|
||||||
|
/* child */
|
||||||
|
else if (0 == pid) {
|
||||||
|
execvp(argv[0], argv);
|
||||||
|
exit(errno);
|
||||||
|
}
|
||||||
|
/* parent */
|
||||||
|
else {
|
||||||
|
while ((0 != waitpid(pid, &status, 0)) &&
|
||||||
|
(! WIFEXITED(status)) && (EINTR == errno));
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
10
src/lam/util/few.h
Обычный файл
10
src/lam/util/few.h
Обычный файл
@ -0,0 +1,10 @@
|
|||||||
|
/*
|
||||||
|
* $HEADER$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef LAM_FEW_H
|
||||||
|
#define LAM_FEW_H
|
||||||
|
|
||||||
|
int lam_few (char *argv[]);
|
||||||
|
|
||||||
|
#endif /* LAM_FEW_H */
|
Загрузка…
x
Ссылка в новой задаче
Block a user