Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!utgpu!water!watmath!clyde!rutgers!cmcl2!husc6!think!ames!sdcsvax!ucsdhub!hp-sdd!hplabs!hpda!hpcupt1!hpisod2!decot
From: decot@hpisod2.UUCP
Newsgroups: comp.lang.c
Subject: Re: stdio error detection
Message-ID: <2550035@hpisod2.HP.COM>
Date: Fri, 4-Dec-87 16:41:02 EST
Article-I.D.: hpisod2.2550035
Posted: Fri Dec  4 16:41:02 1987
Date-Received: Wed, 9-Dec-87 22:08:25 EST
References: <289@cresswell.quintus.UUCP>
Organization: Hewlett Packard, Cupertino
Lines: 195




     EEEERRRRRRRRCCCCTTTTLLLL((((2222))))                 EEEExxxxppppeeeerrrriiiimmmmeeeennnnttttaaaallll                  EEEERRRRRRRRCCCCTTTTLLLL((((2222))))




     NNNNAAAAMMMMEEEE
          errctl - specify what to do when system calls fail

     SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
          iiiinnnntttt ((((((((****eeeerrrrrrrrccccttttllll)))) ((((_f_u_n_c))))))))
          iiiinnnntttt ((((****_f_u_n_c))))(((())));;;;

          ####iiiinnnncccclllluuuuddddeeee <<<>>>
          ####iiiinnnncccclllluuuuddddeeee <<<>>>

          iiiinnnntttt _f_u_n_c ((((_c_a_l_l_i_d,,,, _s_y_s_e_r_r_n_o,,,, _r_e_t_v_a_l,,,, _a_r_g_s))))
          iiiinnnntttt _c_a_l_l_i_d,,,, _s_y_s_e_r_r_n_o,,,, ****_r_e_t_v_a_l,,,, ****_a_r_g_s;;;;

     DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
          _E_r_r_c_t_l specifies what do to when the calling process calls a
          function listed in Section 2 of this manual and the function
          fails.  This occurs whenever the system would ordinarily set
          the  value  of the external integer variable eeeerrrrrrrrnnnnoooo to a non-
          zero value.  Using this facility, the programmer can  supply
          a custom function to provide modular handling of exceptional
          errors.

          The value of _f_u_n_c indicates the  action  to  be  taken  when
          subsequent system calls fail.  The possible values are:

          EEEERRRRRRRR____DDDDFFFFLLLL        Upon the failure of a system  call,  set  the
                         value  of  eeeerrrrrrrrnnnnoooo  accordingly, and return the
                         value  ordinarily  returned   by   the   call
                         (usually ----1111) unmodified.  This is the default
                         action.

          EEEERRRRRRRR____IIIIGGGGNNNN        Upon the failure of a  system  call,  do  not
                         change  the  value  of  eeeerrrrrrrrnnnnoooo, but return the
                         value  ordinarily  returned   by   the   call
                         (usually ----1111) unmodified.

          _f_u_n_c_t_i_o_n _a_d_d_r_e_s_s
                         Upon the failure of a system call, invoke the
                         indicated  handling  function.  The arguments
                         passed  to  the  handling  function  are   as
                         follows:

                         _c_a_l_l_i_d         A   system   call   identifier
                                        representing  the  system call
                                        that failed.  Values  for  the
                                        identifier  are  of  the  form
                                        SSSSYYYYSSSS_____C_A_L_L, where  _C_A_L_L  is  the
                                        name   of   the   system  call
                                        converted   to   upper   case.
                                        These  values  are  defined in
                                        <<<>>>.



     Hewlett-Packard Company       - 1 -                   Dec 4, 1987






     EEEERRRRRRRRCCCCTTTTLLLL((((2222))))                 EEEExxxxppppeeeerrrriiiimmmmeeeennnnttttaaaallll                  EEEERRRRRRRRCCCCTTTTLLLL((((2222))))




                         _s_y_s_e_r_r_n_o       The eeeerrrrrrrrnnnnoooo value  corresponding
                                        to the failure (see _e_r_r_n_o(2)).

                         _r_e_t_v_a_l         A  pointer   to   a   location
                                        containing  the  integer value
                                        that   ordinarily   would   be
                                        returned  by the failed system
                                        call.

                         _a_r_g_s           An integer  pointer  parameter
                                        whose   usage   is   currently
                                        implementation-defined.

                         The external integer variable  eeeerrrrrrrrnnnnoooo  is  not
                         affected unless explicitly changed during the
                         execution of the handling function.

                         The integer value  left  in  *_r_e_t_v_a_l  by  the
                         handling  function  is  returned  to the user
                         program as the apparent return value  of  the
                         system call.

                         The integer value returned  by  the  handling
                         function determines whether the failed system
                         call is to be restarted after  completion  of
                         the handling function.  If the returned value
                         is  non-zero,  the  system   call   will   be
                         restarted.

          The status of system call error  handling  is  inherited  by
          child  processes  created by _f_o_r_k(_2) or _v_f_o_r_k(_2), and is set
          to EEEERRRRRRRR____DDDDFFFFLLLL on successful calls to _e_x_e_c(2).

     RRRREEEETTTTUUUURRRRNNNN VVVVAAAALLLLUUUUEEEE
          _E_r_r_c_t_l(2) returns the most recently installed previous value
          of _f_u_n_c installed by the calling process.

     EEEEXXXXAAAAMMMMPPPPLLLLEEEESSSS
          In a program that occasionally creates additional processes,
          changing  demand  for  system  resources  could  prevent the
          processes from being created.  In such a case, _e_r_r_c_t_l(2) can
          be used to handle such exceptions flexibly:

               ####iiiinnnncccclllluuuuddddeeee <<<>>>
               ####iiiinnnncccclllluuuuddddeeee <<<>>>

               iiiinnnntttt eeeerrrrrrrrhhhhaaaannnnddddlllleeeerrrr(((())));;;;

               mmmmaaaaiiiinnnn(((())))
               {{{{
                   ............



     Hewlett-Packard Company       - 2 -                   Dec 4, 1987






     EEEERRRRRRRRCCCCTTTTLLLL((((2222))))                 EEEExxxxppppeeeerrrriiiimmmmeeeennnnttttaaaallll                  EEEERRRRRRRRCCCCTTTTLLLL((((2222))))




                    ((((vvvvooooiiiidddd)))) eeeerrrrrrrrccccttttllll((((eeeerrrrrrrrhhhhaaaannnnddddlllleeeerrrr))));;;;
                   ............
                    ssssyyyysssstttteeeemmmm((((""""ssssoooommmmeeeetttthhhhiiiinnnngggg""""))));;;;
                   ............
               }}}}

               iiiinnnntttt eeeerrrrrrrrhhhhaaaannnnddddlllleeeerrrr((((ccccaaaalllllllliiiidddd,,,, ssssyyyysssseeeerrrrrrrrnnnnoooo,,,, rrrreeeettttvvvvaaaallll,,,, aaaarrrrggggssss))))
               iiiinnnntttt ccccaaaalllllllliiiidddd,,,, ssssyyyysssseeeerrrrrrrrnnnnoooo,,,, ****rrrreeeettttvvvvaaaallll,,,, ****aaaarrrrggggssss;;;;
               {{{{
                   sssswwwwiiiittttcccchhhh ((((ccccaaaalllllllliiiidddd))))
                   {{{{
                    ccccaaaasssseeee SSSSYYYYSSSS____FFFFOOOORRRRKKKK::::
                    ccccaaaasssseeee SSSSYYYYSSSS____VVVVFFFFOOOORRRRKKKK::::
                        iiiiffff ((((ssssyyyysssseeeerrrrrrrrnnnnoooo ======== EEEEAAAAGGGGAAAAIIIINNNN))))
                        {{{{
                         sssslllleeeeeeeepppp((((4444))));;;;
                         rrrreeeettttuuuurrrrnnnn ((((1111))));;;;
                        }}}}
                   }}}}

                   rrrreeeettttuuuurrrrnnnn ((((0000))));;;;
               }}}}

     SSSSEEEEEEEE AAAALLLLSSSSOOOO
          intro(2), errno(2), exec(2), fork(2).





























     Hewlett-Packard Company       - 3 -                   Dec 4, 1987