Re: [PATCH] script: evaluate errno only if read() sets it

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

 



I have a question and a comment about my own patch :)

On Thursday 02 July 2015, Ruediger Meier wrote:

> @@ -367,7 +365,7 @@ static void handle_signal(struct script_control
> *ctl, int fd)
>
>  	bytes = read(fd, &info, sizeof(info));
>  	if (bytes != sizeof(info)) {
> -		if (errno == EAGAIN)
> +		if (bytes < 0 && errno == EAGAIN)
>  			return;

Should we also return on EINTR here like we do in handle_io()?

>  		fail(ctl);
>  	}


And I see some more potential problems. For example see this snippet 
from handle_io();

	bytes = read(fd, buf, sizeof(buf));
	if (bytes < 0) {
		DBG(IO, ul_debug(" read failed"));
		if (errno == EAGAIN || errno == EINTR)
			return;
		fail(ctl);
	}

We are using errno after DBG(). But in theory printf() or whatever we do 
in DBG() could change errno. Wouldn't it be a good idea to write 
generally all DBG macros errno-invariant?

cu,
Rudi
--
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