View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000138 | 1003.1(2008)/Issue 7 | System Interfaces | public | 2009-08-26 16:01 | 2013-04-16 13:06 |
Reporter | geoffclare | Assigned To | ajosey | ||
Priority | normal | Severity | Comment | Type | Error |
Status | Closed | Resolution | Accepted As Marked | ||
Name | Geoff Clare | ||||
Organization | The Open Group | ||||
User Reference | |||||
Section | sem_timedwait | ||||
Page Number | 1826 | ||||
Line Number | 58299 | ||||
Interp Status | --- | ||||
Final Accepted Text | 0000138:0000206 | ||||
Summary | 0000138: errno indeterminate in sem_timedwait() example | ||||
Description | The example code on the sem_timedwait() page has a signal handler that does not save and restore errno, and calls functions that can change errno. Thus the value of errno where it is used in main() is indeterminate. The example also exhibits poor programming practice in its use of hard-coded constants (24 and 18) in the write() calls in the handler. | ||||
Desired Action | Replace the definition of the handler() function (lines 58299-58307) with: static void handler(int sig) { int sav_errno = errno; static char info_msg[] = "sem_post() from handler\n"; write(STDOUT_FILENO, info_msg, sizeof info_msg - 1); if (sem_post(&sem) == -1) { static char err_msg[] = "sem_post() failed\n"; write(STDERR_FILENO, err_msg, sizeof err_msg - 1); _exit(EXIT_FAILURE); } errno = sav_errno; } | ||||
Tags | tc1-2008 |
|
Make the info_msg[] and err_msg[] arrays const.static void handler(int sig) { int sav_errno = errno; static const char info_msg[] = "sem_post() from handler\n"; write(STDOUT_FILENO, info_msg, sizeof info_msg - 1); if (sem_post(&sem) == -1) { static const char err_msg[] = "sem_post() failed\n"; write(STDERR_FILENO, err_msg, sizeof err_msg - 1); _exit(EXIT_FAILURE); } errno = sav_errno; } |
Date Modified | Username | Field | Change |
---|---|---|---|
2009-08-26 16:01 | geoffclare | New Issue | |
2009-08-26 16:01 | geoffclare | Status | New => Under Review |
2009-08-26 16:01 | geoffclare | Assigned To | => ajosey |
2009-08-26 16:01 | geoffclare | Name | => Geoff Clare |
2009-08-26 16:01 | geoffclare | Organization | => The Open Group |
2009-08-26 16:01 | geoffclare | Section | => sem_timedwait |
2009-08-26 16:01 | geoffclare | Page Number | => 1826 |
2009-08-26 16:01 | geoffclare | Line Number | => 58299 |
2009-08-26 16:01 | geoffclare | Interp Status | => --- |
2009-08-27 15:44 | nick | Note Added: 0000206 | |
2009-08-27 15:44 | nick | Final Accepted Text | => See note 0000206 |
2009-08-27 15:44 | nick | Resolution | Open => Accepted As Marked |
2009-08-27 15:45 | nick | Status | Under Review => Resolved |
2009-08-27 15:46 | nick | Final Accepted Text | See note 0000206 => bugnote: 206 |
2009-08-27 15:46 | nick | Final Accepted Text | bugnote: 206 => 0000138:0000206 |
2010-08-27 13:13 | ajosey | Tag Attached: tc1-2008 | |
2013-04-16 13:06 | ajosey | Status | Resolved => Closed |