[PATCH] getty: Wait until all output written to stdout has been transmitted

Rich Felker dalias at aerifal.cx
Mon Jan 24 16:47:37 UTC 2011


On Mon, Jan 24, 2011 at 09:03:45AM +0100, Peter Korsgaard wrote:
> Ok, what about:
> 
> +	/* Wait up to 5 seconds for the output buffer to drain */
> +	signal(SIGALRM, record_signo);
> +	alarm(5);
> +	tcdrain(STDIN_FILENO);
> +	alarm(0);
> +	signal(SIGALRM, SIG_DFL);
>  	tcflush(STDIN_FILENO, TCIOFLUSH);

How does this work? Normally plain signal sets SA_RESTART and won't be
interrupting. You need sigaction without SA_RESTART, or the BB
wrapper, to get the interrupting behavior that's desired. Was this
code tested?

Rich


More information about the busybox mailing list