- /* Close stdin entirely, redirect stdout to /tmp/program.log, and
- * redirect stderr to a pipe so we can put error messages into
- * exceptions. We'll only use these messages should mount also
- * return an error code.
+ /* Pull stdin from /dev/tty5 and redirect stdout and stderr to the pipes
+ * so we can log the output and put error messages into exceptions.
+ * We'll only use these messages should mount also return an error
+ * code.
*/
- fd = open("/dev/tty5", O_RDONLY);
+ tty_fd = open("/dev/tty5", O_RDONLY);
close(STDIN_FILENO);
- dup2(fd, STDIN_FILENO);
- close(fd);
+ dup2(tty_fd, STDIN_FILENO);
+ close(tty_fd);
Are you sure this is safe? What about the case when stderr gets filled by enough data to fill the kernel buffer for that pipe while you are waiting for stdout? In my experience the calling program then block until you read some data from the pipe.. but you are waiting for stdout so I think you could end up in deadlock here.
Martin
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
Are you sure this is safe? What about the case when stderr gets filled by enough data to fill the kernel buffer for that pipe while you are waiting for stdout? In my experience the calling program then block until you read some data from the pipe.. but you are waiting for stdout so I think you could end up in deadlock here.
Martin
Nice catch, this is something I did not consider. Looking at 'man 7
pipe' the capacity is 65kB so I will just assume there is not going to
be more than that written by mount to stderr or stdout. I'll add a
comment about it in the source code. If either problems appear or
there's more places we need this construction I am going to come up with
a general solution.
Ales
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list