diff options
author | Joey Hess <joey@kodama.kitenet.net> | 2008-04-11 15:53:38 -0400 |
---|---|---|
committer | Joey Hess <joey@kodama.kitenet.net> | 2008-04-11 15:53:38 -0400 |
commit | 0ff304e2ca860e51e75bbfc08290e364e94cb32e (patch) | |
tree | ad7874aed988d79842ef07cc7f5776c180a117a8 /sponge.c | |
parent | c391b00d2837d1571ac1d361551378adf19ae83f (diff) | |
download | moreutils-0ff304e2ca860e51e75bbfc08290e364e94cb32e.tar.gz |
set up signal handlers before creating temp file
Avoids a small race..
Diffstat (limited to 'sponge.c')
-rw-r--r-- | sponge.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -237,10 +237,13 @@ int main (int argc, char **argv) { if ((bufsize*2) >= mem_available) { if (!tmpfile) { /* umask(077); FIXME: Should we be setting umask, or using default? */ - struct cs_status cs = cs_enter(); - int tmpfd = mkstemp(tmpname); - atexit(onexit_cleanup); // solaris on_exit(onexit_cleanup, 0); + struct cs_status cs; + int tmpfd; + trapsignals(); + cs = cs_enter(); + tmpfd = mkstemp(tmpname); + atexit(onexit_cleanup); // solaris on_exit(onexit_cleanup, 0); cs_leave(cs); if (tmpfd < 0) { perror("mkstemp failed"); |