On Wed, Feb 02, 2011 at 08:24:28PM +0100, Denys Vlasenko wrote:
> +static volatile int timed_out;
> +
> +static void alrm_catcher(int i)
> +{
> + printf ("\007timed out waiting for input: auto-logout\n");
> + timed_out = 1;
> + return;
> +}
>
> (1) printf in signal handler is a bad idea.
It's not just a bad idea; it *will* lead to memory corruption and/or
deadlock when it happens while stdout is in use. Using dprintf instead
should be safe even though POSIX doesn't require it to be safe.
> (2) you need to save/restore errno around printf.
This is a much smaller issue, but yes...
Rich
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox