On Dec 20 Paul Everlund wrote: > On Fri, 20 Dec 2002, Paul Everlund wrote: > > Found an error in my reply... > > > On Fri, 20 Dec 2002, Aaron Burke wrote: > > > [big snip] > > > I think execlp is writing over your current process. So first your > > process is exchanged with ppp, then ppp is exchanged with screen. You > > have to make a copy of your current process, a.out, by using fork, and > > then exchange the process image in this copy using execlp. > > Correction... Your a.out process is replaced with ppp, then nothing > else happens, as screen never is called du to the replacement.
the process image replaced with "su" and the second execlp() newer called if the first execlp() call succeeds... (which won't) else replaced with "screen" if the second execlp() call succeeds (which won't)... (if exec??() returns, then an error has occured) Here is some code for the OP to start with: #include <sys/types.h> #include <sys/wait.h> #include <unistd.h> #include <stdio.h> #include <sysexits.h> int main(void) { pid_t pid; int s; switch (pid = fork()) { case -1: perror("fork"); exit(EX_OSERR); case 0: /* I'm the child. */ execlp("/usr/bin/su", "/usr/bin/su", "arg1", "arg2", "argn", NULL); /* kaboom */ /* perror("execlp"); */ exit(EX_SOFTWARE); default: /* I'm the parent */ waitpid(pid, &s, 0); break; } return WEXITSTATUS(s); } -andrew To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-questions" in the body of the message