Re: some craziness in wall's ttymsg.c

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

 



 Hi Alan,

On Sat, Jun 30, 2007 at 12:28:19AM -0400, Alan Curry wrote:
> 
> --- src/usr.bin/wall/ttymsg.c	1999/08/28 01:07:31	1.4
> +++ src/usr.bin/wall/ttymsg.c	2000/06/09 19:38:28	1.5
> @@ -120,7 +120,7 @@ ttymsg(iov, iovcnt, line, tmout)
>  			continue;
>  		}
>  		if (errno == EWOULDBLOCK) {
> -			int cpid, off = 0;
> +			int cpid;
>  
>  			if (forked) {
>  				(void) close(fd);
> @@ -143,7 +143,7 @@ ttymsg(iov, iovcnt, line, tmout)
>  			(void) signal(SIGTERM, SIG_DFL); /* XXX */
>  			(void) sigsetmask(0);
>  			(void) alarm((u_int)tmout);
> -			(void) fcntl(fd, O_NONBLOCK, &off);
> +			(void) fcntl(fd, F_SETFL, 0);	/* clear O_NONBLOCK */

 I think more paranoid and readable way is:

    flags = fcntl(fd, F_GETFL);
    fcntl(flags, F_SETFL, (long) (flags & ~O_NONBLOCK)))

 although it's probably not necessary for ttymsg.c where is O_NONBLOCK
 only.

    Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
-
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" 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