Email List: Xaustin-review-lX
[All Lists]

Defect in XSH sem_init()

To: yyyyyyyyyyyyyyy@xxxxxxxxxxxxx
Subject: Defect in XSH sem_init()
From: yyyyyyyyy@xxxxxxx
Date: Mon, 23 Oct 2006 04:53:06 +0100 (BST)
        Defect report from : Michael Kerrisk , self

(Please direct followup comments direct to yyyyyyyyyyyyyy@xxxxxxxxxxxxx)

@ page 1278 line 40311 section sem_init() objection {sem_open-success-return}

Problem:

Edition of Specification (Year): 2004

Defect code :  2. Omission

(This is really a report against the upcoming revision, which carries the same 
text.  Line numbers references are to TC2.)

The specification of sem_init() includes the following text at lines 
40311-40312:

    Upon successful completion, the sem_init( ) function 
    shall initialize the semaphore in sem. Otherwise, it 
    shall return −1 and set errno to indicate the error.

This wording dates back to at least least SUSv2.  However, POSIX.1-2004 does 
have the following rationale text at lines:

40325 Although this volume of IEEE Std 1003.1-200x fails to specify a 
successful return value, it is
40326 likely that a later version may require the implementation to return a 
value of zero if the call to
40327 sem_init( ) is successful.

However, draft 1 of the revision has not rectified the situation: there is 
still no text describing the return value for a successful call.

All of the manual pages that I have checked describe a return value of 0 on 
success.  The one exception is Solaris, which has similar wording to the 
specification.  However, checking the source code of OpenSolaris shows that 
sem_init() does indeed return 0 on success on that implementation.

The specification should fulfill its earlier commitment and specify the return 
value for the success case.

Action:

Replace lines 40311 to 40312 with the following:

    Upon successful completion, the sem_init( ) 
    function shall initialize the semaphore in sem, 
    and return 0. Otherwise, it shall return −1 and 
    set errno to indicate the error.

Remove lines 40324 to 40327.

<Prev in Thread] Current Thread [Next in Thread>
  • Defect in XSH sem_init(), mtk-lists <=