Advertisement
Guest User

Untitled

a guest
Dec 20th, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.68 KB | None | 0 0
  1. char new_line[1];
  2.         new_line[0] = 10;
  3.         int **fd = (int **) malloc (no_of_processes * sizeof(int *));
  4.         //write (fd[2][1], argv[2], strlen (argv[2]));
  5.         for (int i = 0; i < no_of_processes; i++) {
  6.                 fd[i] = (int *) malloc (2 * sizeof(int));
  7.                 if (pipe(fd[i]) == -1) {
  8.                         printf ("Pipe fail");
  9.                 }
  10.                 for (int j = i; j < count; j += no_of_processes) {
  11.                         printf ("-\n");
  12.                         write (fd[1][i], argv[j], strlen (argv[j]));
  13.                         write (fd[i][1], new_line, 1);
  14.                         printf ("%d\n", j);
  15.                 }
  16.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement