Endil

lab-next parent

Dec 11th, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include <ctime>
  2. #include <unistd.h>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     ofstream fout;
  10.     fout.open("lab-next.txt");
  11.     char buffer[80];
  12.     time_t seconds;
  13.     tm* timeinfo;
  14.     char* format = "%H:%M:%S";
  15.     int pid = getpid();
  16.     execl("./lab-next-d1", "lab-next-d1", NULL, (char*)0);
  17.     execl("./lab-next-d2", "lab-next-d2", NULL, (char*)0);
  18.     execl("./lab-next-d3", "lab-next-d3", NULL, (char*)0);
  19.     for (int k=0; k<=100; k++) {
  20.         seconds = time (NULL);
  21.         timeinfo = localtime (&seconds);
  22.         strftime(buffer, 80, format, timeinfo);
  23.         fout << k << " " << pid << " " << buffer << "\n";
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment