Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ncurses.h>
- #include<stdlib.h>
- #include<stdio.h>
- #include <ctime>
- #include <string>
- #include <unistd.h>
- #include <sys/wait.h>
- #include <sys/types.h>
- using namespace std;
- int main()
- {
- initscr();
- start_color();
- time_t now;
- pid_t pid = fork();
- switch(pid){
- case -1:
- {
- perror("fork"); /* произошла ошибка */
- exit(1); /*выход из родительского процесса*/
- }
- case 0:
- {
- clear();
- time(&now);
- char str[26];
- ctime_r(&now,str);
- init_pair(1, COLOR_RED, COLOR_BLACK);
- attron(COLOR_PAIR(1));
- printw("\n\n CHILDW :");
- mvprintw(10,30,"%s",str);
- refresh();
- getch();
- attroff(COLOR_PAIR(1));
- exit(0);
- }
- default:
- {
- clear();
- wait(NULL);
- time(&now);
- char str[26];
- ctime_r(&now,str);
- init_pair(1, COLOR_RED, COLOR_BLACK);
- attron(COLOR_PAIR(1));
- printw("\n PARENT\n");
- mvprintw(20,30,"%s",str);
- refresh();
- getch();
- }}
- endwin();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement