Changeset 2173 for trunk/src


Ignore:
Timestamp:
Jul 3, 2005, 5:40:02 AM (20 years ago)
Author:
bird
Message:

Clear FD_CLOEXEC on the handle returned by dup, dup2 and fcntl(F_DUPFD).

Location:
trunk/src/emx
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/ChangeLog.LIBC

    • Property cvs2svn:cvs-rev changed from 1.86 to 1.87
    r2172 r2173  
    1313        o Fixed mixup in fts.c port.
    1414        o Replaced the EMX ftw with the BSD one so we implement the SuS specs.
     15
    1516
    16172005-07-01: knut st. osmundsen <[email protected]>
  • trunk/src/emx/include/emx/io.h

    • Property cvs2svn:cvs-rev changed from 1.17 to 1.18
    r2172 r2173  
    496496PLIBCFH __libc_FH(int fh);
    497497int     __libc_FHEx(int fh, __LIBC_PFH *ppFH);
     498
    498499
    499500
  • trunk/src/emx/src/lib/libc.def

    • Property cvs2svn:cvs-rev changed from 1.128 to 1.129
    r2172 r2173  
    18911891    "__obstack_newchunk" @1891
    18921892    "__std_nftw" @1892
     1893
  • trunk/src/emx/src/lib/sys/__dup.c

    • Property cvs2svn:cvs-rev changed from 1.8 to 1.9
    r2172 r2173  
    99#include <emx/io.h>
    1010#include <emx/syscalls.h>
     11
    1112#include "syscalls.h"
    1213#include "b_fs.h"
     
    6162                pFHNew->Dev         = pFH->Dev;
    6263                pFHNew->pFsInfo     = __libc_back_fsInfoObjAddRef(pFH->pFsInfo);
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
    6374            }
    6475            else
  • trunk/src/emx/src/lib/sys/__dup2.c

    • Property cvs2svn:cvs-rev changed from 1.7 to 1.8
    r2172 r2173  
    88#include <emx/syscalls.h>
    99#include <emx/io.h>
     10
    1011#include "syscalls.h"
    1112#include "b_fs.h"
     
    9495                pFHNew->Dev         = pFH->Dev;
    9596                pFHNew->pFsInfo     = __libc_back_fsInfoObjAddRef(pFH->pFsInfo);
     97
     98
     99
     100
     101
     102
     103
     104
     105
     106
    96107            }
    97108            else
  • trunk/src/emx/src/lib/sys/__fcntl.c

    • Property cvs2svn:cvs-rev changed from 1.12 to 1.13
    r2172 r2173  
    193193{
    194194    LIBCLOG_ENTER("pFH=%p hFile=%d arg=%#x\n", (void *)pFH, hFile, arg);
    195     int     rc;
    196     ULONG   fulState;
    197     FS_VAR();
    198 
    199     FS_SAVE_LOAD();
    200     rc = DosQueryFHState(hFile, &fulState);
     195
     196    /*
     197     * Calc new flags.
     198     */
     199    unsigned fFlags = pFH->fFlags;
     200    fFlags = (fFlags & ~__LIBC_FH_FDFLAGS_MASK) | (arg << __LIBC_FH_FDFLAGS_SHIFT);
     201    if (arg & FD_CLOEXEC)
     202        fFlags |= O_NOINHERIT;
     203    else
     204        fFlags &= ~O_NOINHERIT;
     205
     206    /*
     207     * Update the flags.
     208     */
     209    int rc = __libc_FHSetFlags(pFH, hFile, fFlags);
    201210    if (!rc)
    202     {
    203         ULONG fulNewState;
    204         LIBC_ASSERTM(     ( (fulState & OPEN_FLAGS_NOINHERIT) != 0 )
    205                       ==  (   (pFH->fFlags & (O_NOINHERIT | (FD_CLOEXEC << __LIBC_FH_FDFLAGS_SHIFT)))
    206                            == (O_NOINHERIT | (FD_CLOEXEC << __LIBC_FH_FDFLAGS_SHIFT)) ),
    207                      "Inherit flags are out of sync for file hFile %d (%#x)! fulState=%08lx fFlags=%08x\n",
    208                      hFile, hFile, fulState, pFH->fFlags);
    209         if (arg & FD_CLOEXEC)
    210             fulNewState = fulState | OPEN_FLAGS_NOINHERIT;
    211         else
    212             fulNewState = fulState & ~OPEN_FLAGS_NOINHERIT;
    213         if (fulNewState != fulState)
    214         {
    215             fulNewState &= 0x7f88; /* Mask the flags accepted the API. */
    216             rc = DosSetFHState(hFile, fulNewState);
    217         }
    218     }
    219     FS_RESTORE();
    220 
    221     if (!rc)
    222     {
    223         unsigned fFlags = pFH->fFlags;
    224         fFlags = (fFlags & ~__LIBC_FH_FDFLAGS_MASK) | (arg << __LIBC_FH_FDFLAGS_SHIFT);
    225         if (arg & FD_CLOEXEC)
    226             fFlags |= O_NOINHERIT;
    227         else
    228             fFlags &= ~O_NOINHERIT;
    229         __atomic_xchg(&pFH->fFlags, fFlags);
    230211        LIBCLOG_RETURN_INT(0);
    231     }
    232 
    233     /* error! */
    234     _sys_set_errno(rc);
     212    errno = -rc;
    235213    LIBCLOG_RETURN_INT(-1);
    236214}
  • trunk/src/emx/src/lib/sys/filehandles.c

    • Property cvs2svn:cvs-rev changed from 1.20 to 1.21
    r2172 r2173  
    11431143    return rc;
    11441144}
     1145
     1146
     1147
     1148
     1149
     1150
     1151
     1152
     1153
     1154
     1155
     1156
     1157
     1158
     1159
     1160
     1161
     1162
     1163
     1164
     1165
     1166
     1167
     1168
     1169
     1170
     1171
     1172
     1173
     1174
     1175
     1176
     1177
     1178
     1179
     1180
     1181
     1182
     1183
     1184
     1185
     1186
     1187
     1188
     1189
     1190
     1191
     1192
     1193
     1194
     1195
     1196
     1197
     1198
     1199
     1200
    11451201
    11461202
Note: See TracChangeset for help on using the changeset viewer.