第五讲系统调用.ppt

如果进程把在脱离终端的控制进程之后,试图读取控制终端,它将会 收到一个SIGTTIN信号,挂起该进程。 例 :系统有一个默认的SIGTTIN的处理程序,该例中重写了该程序。 /*pgrp3.c*/ #include stdio.h #include signal.h #include fcntl.h void sigttinHandler (); main () { int status; char str [100]; if (fork () == 0) /* Child */ { signal (SIGTTIN, sigttinHandler); /* Install handler */ setpgid (0, getpid ()); /* Place myself in a new process group */ printf (Enter a string: ); scanf (%s, str); /* Try to read from control terminal */ printf (You entered %s\n, str); } * 例 : (续) else /* Parent */ { wai

文档评论(0)

1亿VIP精品文档

相关文档