Ignore:
Timestamp:
Jun 26, 2020, 7:16:26 PM (5 years ago)
Author:
bird
Message:

kmk: Avoid setting umask just to get it, store the current value in a global variable (g_fUMask). The umask(0777) call in cp.c raced other code (kmk_append) that created files and directories, leaving us with read-only files sometimes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/kmkbuiltin/setmode.c

    r2113 r3389  
    100100#endif /* !S_ISTXT */
    101101
     102extern mode_t g_fUMask; /* Initialize in main() and keep up to date. */
     103
     104
    102105/*
    103106 * Given the old mode and an array of bitcmd structures, apply the operations
     
    223226        (void)sigprocmask(SIG_BLOCK, &signset, &sigoset);
    224227#endif
    225         (void)umask(mask = umask(0));
     228        mask = g_fUMask;
     229        assert(mask == umask(g_fUMask));
    226230        mask = ~mask;
    227231#ifndef _MSC_VER
Note: See TracChangeset for help on using the changeset viewer.