Unix Programming - When the SIGTTOU is delivered

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > June 2007 > When the SIGTTOU is delivered





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author When the SIGTTOU is delivered
Bin Chen

2007-06-25, 1:22 am

Hi,

The manual said it is delivered when a background process try to write
to control tty, so I wrote a small program to test, it can't receive
the signal.

gcc a.c -o a
../a &

a.c:
#include <signal.h>
#include <unistd.h>
#include <stdio.h>

void ttin()
{
printf("ttin.\n");
return;
}

void ttou()
{
printf("ttou.\n");
return;
}

main()
{
signal(SIGTTIN, ttin);
signal(SIGTTOU, ttou);

// getchar();
putchar('a');
}

So what's the problem.

Thanks.
Bin

Alan Curry

2007-06-25, 1:22 am

In article <1182739515.093413.224200@j4g2000prf.googlegroups.com>,
Bin Chen <binary.chen@gmail.com> wrote:
>Hi,
>
>The manual said it is delivered when a background process try to write
>to control tty, so I wrote a small program to test, it can't receive
>the signal.


Hopefully your manual also says, somewhere, that SIGTTOU is only sent if the
tty has the TOSTOP flag enabled. stty tostop, or see tcsetattr(3) to set it
from within your C code.

>void ttou()
>{
> printf("ttou.\n");


Nasty. Writing to the tty from within the signal handler that gets invoked
when you try to write to the tty. And it's in the background so there's no
^C'ing it. You got me. (I kill -9'ed it from another tty).

> return;
>}


--
Alan Curry
pacman@world.std.com
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com