ENOTTY error when executing cp(1)

Jan B. Andersen jba at harald.ruc.dk
Thu Sep 14 05:20:59 AEST 1989


>In article <2556 at taux01.UUCP> amos at taux01.UUCP (Amos Shapir) writes:
>|  To make sure
>|  its value is relevant, always clear errno before doing a system call.

blm at 6sigma.UUCP (Brian Matthews) writes:

> Intro(2) (in my System V manuals) states:

>    "Errno is not cleared on successful calls, so it should be tested
>     only after an error has been indicated."

>The second half of that sentence says to me that errno may be modified
>even if the system call succeeds, so relying on errno staying zero is
>a Bad Thing.  But the first half of the sentence seems to talk about
>clearing errno on success, so the second half might not say anything
>about whether errno is modified on success.

As I see it, the "correct" way to check for errors is by coding something
like this:

  if( some_system_call() ) {
	printf( "errno %d has occured in some_system_call()\n", errno );
	exit( errno );
  }

If you don't like if'ing the call do something like this:

  errno = 0;
  some_system_call();
  if( errno ) {
	...
  }



More information about the Comp.unix.wizards mailing list