X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=pipex_posix.c;h=9df6f38336fdb35164d86d378f2003592e3e8510;hb=bb6c47f77f59067c358579a71cefa1ae65180a30;hp=5d2edfaba6bffe7f5bedb1ed23266a358239c893;hpb=e15efca6667b2673b4c1a5879a6917eab6800e58;p=polyglot.git diff --git a/pipex_posix.c b/pipex_posix.c index 5d2edfa..9df6f38 100644 --- a/pipex_posix.c +++ b/pipex_posix.c @@ -19,7 +19,10 @@ static void my_dup2(int old_fd, int new_fd) ; // pipex_open() -void pipex_open(pipex_t *pipex, const char *name, const char *command){ +void pipex_open(pipex_t *pipex, + const char *name, + const char *working_dir, + const char *command){ char string[StringSize]; int argc; char * ptr; @@ -93,13 +96,18 @@ void pipex_open(pipex_t *pipex, const char *name, const char *command){ /* my_dup2(STDOUT_FILENO,STDERR_FILENO); */ - // launch the new executable file + if(chdir(working_dir)){ + my_fatal("pipex_open(): cannot change directory: %s\n", + strerror(errno)); + } + // launch the new executable file + execvp(argv[0],&argv[0]); // execvp() only returns when an error has occured - my_fatal("engine_open(): execvp(): %s\n",strerror(errno)); + my_fatal("engine_open(): execvp(): %s: %s\n",command,strerror(errno)); } else { // pid > 0 @@ -226,6 +234,13 @@ bool pipex_readln_nb(pipex_t *pipex, char *string){ } } +// pipex_write() + +void pipex_write(pipex_t *pipex, const char *string){ + io_send_queue(pipex->io,"%s",string); +} + + // pipex_writeln() void pipex_writeln(pipex_t *pipex, const char *string){