Hi, After exec(), child clib's startup routine determines buffering mode for stdout (i.e. calls fdopen(1, "w+")). You can setup pseudo-terminal instead of pipe, to make child's stdout line-buffered.
optimistic snippet: ===================================================================== #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(int argc, char *argv[]) { int master_fd, slave_fd; FILE *master_file, *slave_file; char buf[80], *device; master_fd = posix_openpt(O_RDWR | O_NOCTTY); grantpt(master_fd); unlockpt(master_fd); slave_fd = open(device = ptsname(master_fd), O_RDWR | O_NOCTTY); printf("slave device: %s\n", device); master_file = fdopen(master_fd, "r"); slave_file = fdopen(slave_fd, "w+"); if (fork()) { fclose(slave_file); while (fgets(buf, sizeof(buf), master_file)) printf("parent got: %s", buf); } else { // child fclose(master_file); for (int i = 0; i < 500; i++) { sleep(1); fprintf(slave_file, "child's data (%d)\n", i); } } return 0; } ===================================================================== 21.11.09, 09:39, "Till Harbaum / Lists" <li...@harbaum.org>: > Hi, > thanks again for that hint. Unfortunately adding > /* switch to line buffered mode */ > if(setvbuf(fh, NULL, _IOLBF, 0)) > perror("setvbuf(_IOLBF)"); > to the program posted by Dov doesn't change anything. > Are there limitations on changing the buffer mode? E.g. > only the transmitter side can do that? _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list