Re: [PATCH] rfkill: allow user to exit gracefully from event watching loop

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Nov 07, 2017 at 04:08:56PM +0000, Sami Kerola wrote:
> When SIGINT is raised by something else than an user running rfkill the
> watch loop will be killed by that signal with appropriate exit code.

It seems like over-engineering that introduces unnecessary code and
complex semantic. Why do you care about return code when you press
CTRL+C and why it should be different to another situations with
signals? I think we do not have such code in another utils.

> +static void event_signal(int signo, siginfo_t *info,
> +			 void *context __attribute__((__unused__)))
> +{
> +	if (!info->si_pid)
> +		user_ctrl_c = 1;
> +	else {
> +		if (info->si_code == SI_USER)
> +			warnx(_("uid: %d pid: %d sent signal %d, exiting"),
> +			      info->si_uid, info->si_pid, info->si_signo);

We should not use warn/err/printf in signals handlers.

> +		signal(signo, SIG_DFL);
> +		kill(getpid(), signo);
> +	}
> +}

    Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux