Subject: Re: New cat(1) option (was: Re: Possible solution to toolchain/16963 - NBUILDJOBS/METALOG conflict)
To: None <tech-userlevel@netbsd.org>
From: Alan Barrett <apb@cequrux.com>
List: tech-userlevel
Date: 06/08/2002 11:38:00
On Fri, 07 Jun 2002, Mason Loring Bliss wrote:
> +		case 'l':
> +			stdout_lock.l_start = 0;
> +			stdout_lock.l_len = 0;
> +			stdout_lock.l_type = F_WRLCK;
> +			stdout_lock.l_whence = SEEK_SET;
> +			fcntl(STDOUT_FILENO, F_SETLKW, &stdout_lock);
> +			break;

It's probably not a good idea to lock the file before all the options
have been parsed.  If a usage error is combined with an output file that
was already locked, then the command would wait until the stdout file
was locked before it printed the usage message to stderr.

While we are adding flags to cat, how about "-a" flag to do
fcntl(STDOUT_FILENO, O_APPEND) ?

--apb (Alan Barrett)