Complexity of reallocating storage (was users command crap)

Chip Salzenberg chip at tct.uucp
Tue Feb 5 02:14:13 AEST 1991


According to brnstnd at kramden.acf.nyu.edu (Dan Bernstein):
>>    (void) read(fdsess,(char *) &newuid,sizeof(int));
>
>This is guaranteed to work, because fdsess is a regular file that was
>created with at least the int. The only possible problem is a hard I/O
>error or other fatal system error.

That particular "fatal" error -- disk failure -- will not kill the
program.  Instead, it will result in a pty program continuing to run
using wrong data that could have been detected and ignored.  This is
"good programming practice?"

>>    if (chdir(newsuid) == -1)
>>     {
>>      (void) mkdir(newsuid,0700);
>
>This cannot fail unless some renegade sysadmin changes the mode of the
>session directory while pty is running.

Not to protect against that possibility is a strong temptation, but it
certainly is not "good programming practice."

>>      (void) chdir(newsuid);
>>     }
>
>Cannot fail.

Unless the mkdir() failed.
-- 
Chip Salzenberg at Teltronics/TCT     <chip at tct.uucp>, <uunet!pdn!tct!chip>
 "I want to mention that my opinions whether real or not are MY opinions."
             -- the inevitable William "Billy" Steinmetz



More information about the Comp.lang.c mailing list