[comp.lang.c] creat

chris@mimsy.UUCP (Chris Torek) (01/02/87)

In article <404@hadron.UUCP> jsdy@hadron.UUCP (Joseph S. D. Yao) writes:
>>  if (outfile=creat(*++argv,0666),outfile==EOF)
>    I would have made the outfile = ... and if (...) two
>    separate statements, to eschew confusion.  Also, I never
>    make files 0666: that way lies lack of data integrity.

Mode 0666 is almost always correct (on Unix systems).  Exceptions
include `secure' programs (e.g., mail systems), programs creating
temporary files purely for their own uses, and programs that make
use of the umask() system call.  I would write

	if ((outfile = creat(name, 0666)) < 0)
		...

or perhaps

	if ((outfile = open(name, O_WRONLY|O_CREAT, 0666)) < 0)
		...

(I hate having to fix programs to make group writable files group
writable.)
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690)
UUCP:	seismo!mimsy!chris	ARPA/CSNet:	chris@mimsy.umd.edu