10 #define PROGRAM_SIZE 100
13 #define strfieldcpy(to, from) \
15 to[sizeof(to)-1] = '\0'; \
16 strncpy(to, from, sizeof(to)-1); \
19 int execute_program(char *path, char *value, int len)
27 char arg[PROGRAM_SIZE];
28 char *argv[sizeof(arg) / 2];
33 if (strchr(path, ' ')) {
34 strfieldcpy(arg, path);
38 /* don't separate if in apostrophes */
40 argv[i] = strsep(&pos, "\'");
44 argv[i] = strsep(&pos, " ");
66 /* dup write side of pipe to STDOUT */
69 retval = execv(argv[0], argv);
75 /* parent reads from fds[0] */
80 count = read(fds[0], value + i, len - i-1);
94 if (i > 0 && value[i-1] == '\n')
101 if (!WIFEXITED(status) || (WEXITSTATUS(status) != 0))