#include /* 'execle' */ #include /* 'printf' and 'NULL' */ #include /* 'errno' */ #include /* 'ENOENT' and 'ENOMEM' */ char *environ[] = {"PATH=C:\\TEST", NULL}; //extern char **environ; int main(void) { pid_t pid; if ( (pid = fork()) < 0) err_sys("fork error"); else if (pid == 0) { /* specifica il nome e l'ambiente */ if (execle("spp28", "spp28", "arg1", "arg2", NULL, environ) < 0) err_sys("execle error"); } if (waitpid(pid, NULL, 0) < 0) err_sys("wait error"); if ( (pid = fork()) < 0) err_sys("fork error"); else if (pid == 0) { /* specifica il path e eredita l'ambiente */ if (execlp("/home/em/spp28", "spp28", "solo_1_arg", NULL) < 0) err_sys("execlp error"); } exit(0); }