C 语言linux 多进程
#include <stdio.h>
#include <ncurses.h>
#include <unistd.h>
int main()
{
//freopen( "in", "r", stdin );
int pid;
char a;
char b;
initscr();
crmode();
noecho();
keypad( stdscr, true );
pid = fork();
if( pid == 0 )
{
while( 1 )
{
a = getch();
mvprintw( 0, 0, " child : %c", a );
}
}
else
{
while( 1 )
{
a = getch();
mvprintw( 10, 0, "father :%c", a );
}
}
endwin();
return 0;
}
如上面这个程序,为什么不能父进程执行一次以后,就再也不执行了,以后按键一直都是自进程刷新
// 不是不再执行了,而是你刷新的次数太少了