X-Git-Url: http://winboard.nl/cgi-bin?p=polyglot.git;a=blobdiff_plain;f=pipex_posix.c;h=34b32cc8e39cd03e883643c55fc41d5c714aa3f8;hp=5d2edfaba6bffe7f5bedb1ed23266a358239c893;hb=a0f731f21d6aa26dbf7246039a1c66c2ade0533f;hpb=baab92d048b9ba06dada3a17ec51d9e9340d4730 diff --git a/pipex_posix.c b/pipex_posix.c index 5d2edfa..34b32cc 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,8 +96,13 @@ 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 @@ -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){