1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
type=fork();
if(type)
{
ioctl(0,TIOCGPGRP,&tty);
my_printf("tty_pgrp=%d\n",tty);
my_printf("parent : pid=%d pgrp=%d\n",getpid(),getpgid(getpid()));
// my_printf("tty_pgrp is now the child\n");
signal(SIGINT,pere);
while(1);
}
else //processus fils
{
setpgid(0,0); //On change le pgid du processus fils.
pgid=getpgid(0);
test=ioctl(0,TIOCSPGRP,&pgid);
// test=ioctl(0,TCSETA,&pgid); Les intructions qui suivent ne s'executent pas et le processus père a toujours accès au terminal car son handler s'execute.
ioctl(0,TIOCGPGRP,&t);
my_printf("%d on tty\n",t);
my_printf("child : pid=%d pgrp=%d %d\n",getpid(),getpgid(getpid()),test);
signal(SIGINT,fils);
while(1);
} |
Partager