Annotation of tftpd/src/exec.c, revision 1.1.2.4
1.1.2.1 misho 1: #include "global.h"
1.1.2.2 misho 2: #include "exec.h"
1.1.2.1 misho 3:
4:
1.1.2.3 misho 5: void *
6: execProg(sched_task_t *task)
7: {
1.1.2.4 ! misho 8: pid_t pid, res;
! 9: const char *str;
! 10: char port[STRSIZ] = { [0 ... STRSIZ - 1] = 0 },
! 11: opc[STRSIZ] = { [0 ... STRSIZ - 1] = 0 };
! 12: ait_val_t v = AIT_VAL_INITIALIZER(v);
! 13: int stat;
! 14:
1.1.2.3 misho 15: ETRACE();
16:
1.1.2.4 ! misho 17: str = cfg_getAttribute(&cfg, "exec_on", TASK_ARG(task));
! 18: if (!str)
! 19: taskExit(task, NULL);
! 20:
! 21: switch (pid = vfork()) {
! 22: case -1:
! 23: ESYSERR(0);
! 24: break;
! 25: case 0:
! 26: snprintf(opc, STRSIZ, "%hu", (u_short) TASK_DATLEN(task));
! 27: snprintf(port, STRSIZ, "%hu", (u_short) e_n2port(&cli.addr));
! 28: execl(_PATH_BSHELL, _PATH_BSHELL, "-c", str, TASK_ARG(task), opc,
! 29: cli.file, cli.mode, e_n2addr(&cli.addr, &v), port, NULL);
! 30: AIT_FREE_VAL(&v);
! 31: _exit(127);
! 32: break;
! 33: default:
! 34: EVERBOSE(1, "Execute %s", str);
! 35: do {
! 36: res = waitpid(pid, &stat, 0);
! 37: } while (res == -1 && errno == EINTR);
! 38: break;
! 39: }
! 40:
1.1.2.3 misho 41: taskExit(task, NULL);
42: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>