Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion newlib/configure.host
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ newlib_cflags="${newlib_cflags} -DCLOCK_PROVIDED -DMALLOC_PROVIDED -DEXIT_PROVID
*-nanvix*)
default_newlib_io_long_long="yes"
syscall_dir=
newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED -DREENTRANT_SYSCALLS_PROVIDED -DMISSING_SYSCALL_NAMES"
newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED -DREENTRANT_SYSCALLS_PROVIDED -DMISSING_SYSCALL_NAMES -D_NO_SIGPROCMASK"
;;
nios2*)
syscall_dir=
Expand Down
24 changes: 23 additions & 1 deletion newlib/libc/search/hash_page.c
Original file line number Diff line number Diff line change
Expand Up @@ -857,19 +857,41 @@ static int
open_temp(hashp)
HTAB *hashp;
{
/*
* The sigprocmask() bracket below guards the mkstemp + unlink
* window against a signal that would otherwise leave the temp
* file behind. Targets whose newlib build does not provide
* sigprocmask() can opt out of that protection by defining
* _NO_SIGPROCMASK via newlib_cflags in configure.host, in the
* same style as the existing _NO_SIGSET / _NO_POPEN /
* _NO_POSIX_SPAWN opt-outs (see newlib/configure.host).
*
* Effect of the opt-out: the mkstemp + unlink window is no
* longer protected by a blocked signal mask. On a target with
* no asynchronous signal delivery, no handler can run in that
* window so the protection was a no-op anyway. The optional
* fcntl(F_SETFD, ...) on the next line uses the same shape via
* HAVE_FCNTL.
*/
#ifndef _NO_SIGPROCMASK
sigset_t set, oset;
#endif
static char namestr[] = "_hashXXXXXX";

/* Block signals; make sure file goes away at process exit. */
#ifndef _NO_SIGPROCMASK
/* Block signals so the file is guaranteed unlinked. */
(void)sigfillset(&set);
(void)sigprocmask(SIG_BLOCK, &set, &oset);
#endif
if ((hashp->fp = mkstemp(namestr)) != -1) {
(void)unlink(namestr);
#ifdef HAVE_FCNTL
(void)fcntl(hashp->fp, F_SETFD, 1);
#endif
}
#ifndef _NO_SIGPROCMASK
(void)sigprocmask(SIG_SETMASK, &oset, (sigset_t *)NULL);
#endif
return (hashp->fp != -1 ? 0 : -1);
}

Expand Down