The Linux Programming Interface
Pipes and FIFOs 897 o if (write(pfd[1], argv[1], strlen(argv[1])) != strlen(argv[1])) fatal("parent - partial/failed write"); a ...
898 Chapter 44 if (argc < 2 || strcmp(argv[1], "--help") == 0) usageErr("%s sleep-time...\n", argv[0]); setbuf(stdout, NULL); ...
Pipes and FIFOs 899 Synchronization using pipes has an advantage over the earlier example of synchro- nization using signals: it ...
900 Chapter 44 After duplicating pfd[1], we now have two file descriptors referring to the write end of the pipe: descriptor 1 a ...
Pipes and FIFOs 901 / Duplicate stdout on write end of pipe; close duplicated descriptor / if (pfd[1] != STDOUT_FILENO) { / Defe ...
902 Chapter 44 When we run the program in Listing 44-4, we see the following: $ ./pipe_ls_wc 24 $ ls | wc -l Verify the results ...
Pipes and FIFOs 903 the write end of the pipe; when writing to the pipe, it is sent a SIGPIPE signal, and gets the EPIPE error, ...
904 Chapter 44 Listing 44-5: Globbing filename patterns with popen() ––––––––––––––––––––––––––––––––––––––––––––––––––––––– pip ...
Pipes and FIFOs 905 t fp = popen(popenCmd, "r"); if (fp == NULL) { printf("popen() failed\n"); continue; } /* Read resulting lis ...
906 Chapter 44 Note also the input checking performed in Listing 44-5 e. This is done to pre- vent invalid input causing popen() ...
Pipes and FIFOs 907 Once a FIFO has been opened, we use the same I/O system calls as are used with pipes and other files (i.e., ...
908 Chapter 44 can be used for reading and writing on the FIFO. Doing this rather subverts the I/O model for FIFOs, and SUSv3 ex ...
Pipes and FIFOs 909 44.8 A Client-Server Application Using FIFOs In this section, we present a simple client-server application ...
910 Chapter 44 Figure 44-6: Using FIFOs in a single-server, multiple-client application Recall that the data in pipes and FIFOs ...
Pipes and FIFOs 911 In the three techniques described in the main text, a single channel (FIFO) is used for all messages from al ...
912 Chapter 44 struct response { /* Response (server --> client) */ int seqNum; /* Start of sequence */ }; –––––––––––––––––– ...
Pipes and FIFOs 913 /* Create well-known FIFO, and open it for reading */ umask(0); / So we get the permissions we want / q if ( ...
914 Chapter 44 Client program Listing 44-8 is the code for the client. The client performs the following steps: z Create a FIFO ...
Pipes and FIFOs 915 if (argc > 1 && strcmp(argv[1], "--help") == 0) usageErr("%s [seq-len...]\n", argv[0]); /* Create ...
916 Chapter 44 If the other end of the FIFO is already open, then the O_NONBLOCK flag has no effect on the open() call—it succes ...
«
43
44
45
46
47
48
49
50
51
52
»
Free download pdf