errno man page on OSF1

Man page or keyword search:  
man Server   12896 pages
apropos Keyword Search (all sections)
Output format
OSF1 logo
[printable version]

errno(5)							      errno(5)

NAME
       errno - Returns error condition value

SYNOPSIS
       #include <errno.h>

DESCRIPTION
       The  errno  external  variable contains the most recent error condition
       set by a function. The symbolic values for  errno  are  listed  in  the
       intro reference page and in the ERRORS section of the individual refer‐
       ence pages for each function.

       The exec() functions set errno to a value of 0 (zero) after  successful
       completion.  Typically,	other  functions  only	set errno to a nonzero
       value.

EXAMPLES
       The following program uses the value of	errno  to  determine  why  the
       requested file could not be opened.  If errno has one of the two tested
       values, the program prints an appropriate message; otherwise, the  pro‐
       gram  uses  the	error() function to print out the appropriate message.
       This program does not have to set errno to a value of 0 (zero)  because
       errno is tested only if the open() function has failed.

       #include	 <errno.h>  #include  <stdio.h>	 #include  <string.h> #include
       <fcntl.h> #include <sys/stat.h> #include <sys/types.h> #define  SLENGTH
       80

       main() {
	   char filespec[SLENGTH], *eol;
	   int opret;
	   while (TRUE) {
	       printf("Enter file to be checked: ");
	       fgets(filespec, SLENGTH, stdin);
	       if ((eol = strchr(filespec, '\n')) != NULL) {
		   *eol = '\0';	 /* Replace newline with null */
		   if (*filespec == '\0') return; /* exit program */
		   opret = open(filespec,O_RDONLY,0);
		   if (opret > 0)
		     printf("%s: File exists\n",filespec);
		   else if (errno == ENOENT)
		     printf("%s: File does not exist\n",filespec);
		   else if (errno == ENOTDIR)
		     printf("%s: Prefix in path is not a directory\n",
		       filespec);
		   else
		     perror(filespec);

	       } else		/* Line entered too long */
		 printf("Line entered is too long\n");
	   } }

NOTES
       To  ensure  that	 your programs are portable, you should not explicitly
       declare errno to be an extern int in your program.  You should rely  on
       the type int declaration in the <errno.h> include file.	Full use.

SEE ALSO
       Functions: intro(2), perror(3), strerror(3)

								      errno(5)
[top]
                             _         _         _ 
                            | |       | |       | |     
                            | |       | |       | |     
                         __ | | __ __ | | __ __ | | __  
                         \ \| |/ / \ \| |/ / \ \| |/ /  
                          \ \ / /   \ \ / /   \ \ / /   
                           \   /     \   /     \   /    
                            \_/       \_/       \_/ 
More information is available in HTML format for server OSF1

List of man pages available for OSF1

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net