cosmopolitan/libc/stdio
Justine Tunney 60cb435cb4
Implement pthread_atfork()
If threads are being used, then fork() will now acquire and release and
runtime locks so that fork() may be safely used from threads. This also
makes vfork() thread safe, because pthread mutexes will do nothing when
the process is a child of vfork(). More torture tests have been written
to confirm this all works like a charm. Additionally:

- Invent hexpcpy() api
- Rename nsync_malloc_() to kmalloc()
- Complete posix named semaphore implementation
- Make pthread_create() asynchronous signal safe
- Add rm, rmdir, and touch to command interpreter builtins
- Invent sigisprecious() and modify sigset functions to use it
- Add unit tests for posix_spawn() attributes and fix its bugs

One unresolved problem is the reclaiming of *NSYNC waiter memory in the
forked child processes, within apps which have threads waiting on locks
2022-10-16 12:25:13 -07:00
..
__fpurge.c Add more missing libc functionality 2022-08-06 10:50:51 -07:00
__fseterr.c Make some foss compatibility improvements 2022-10-14 13:59:34 -07:00
alphasort.c Improve cosmo's conformance to libc-test 2022-10-10 17:52:41 -07:00
append.h Pay off more technical debt 2022-09-12 23:36:56 -07:00
appendd.c Fix bugs and make code tinier 2022-10-09 23:21:34 -07:00
appendf.c Pay off more technical debt 2022-09-12 23:36:56 -07:00
appendr.c Fix bugs and make code tinier 2022-10-09 23:21:34 -07:00
appends.c Pay off more technical debt 2022-09-12 23:36:56 -07:00
appendstrlist.c Pay off more technical debt 2022-09-12 23:36:56 -07:00
appendw.c Fix bugs and make code tinier 2022-10-09 23:21:34 -07:00
appendz.c Fix bugs and make code tinier 2022-10-09 23:21:34 -07:00
big5.inc Add more missing libc functionality 2022-08-06 10:50:51 -07:00
clearerr.c Fix bugs and make code tinier 2022-10-09 23:21:34 -07:00
clearerr_unlocked.c Fix bugs and make code tinier 2022-10-09 23:21:34 -07:00
codepages.inc Add more missing libc functionality 2022-08-06 10:50:51 -07:00
ctermid.c Add ctermid and L_ctermid 2022-07-22 04:39:04 -07:00
dirstream.c Implement pthread_atfork() 2022-10-16 12:25:13 -07:00
dtoa.c Pay off more technical debt 2022-09-12 23:36:56 -07:00
dumphexc.c Pay off more technical debt 2022-09-12 23:36:56 -07:00
ecvt.c Don't relocate file descriptor memory 2022-09-09 16:54:28 -07:00
fbufsize.c Work towards improving signals and processes 2021-01-27 19:34:02 -08:00
fclose.c Pay off more technical debt 2022-09-12 23:36:56 -07:00
fclose_s.c Improve locks and signals 2022-04-12 05:20:17 -07:00
fdopen.c Make important improvements 2022-09-14 22:39:08 -07:00
feof.c Remove stdio lock macros from amalgamation 2022-09-10 12:03:36 -07:00
feof_unlocked.c Make improvements 2022-05-28 00:28:09 -07:00
ferror.c Remove stdio lock macros from amalgamation 2022-09-10 12:03:36 -07:00
ferror_unlocked.c Make improvements 2022-05-28 00:28:09 -07:00
fflush.c Remove stdio lock macros from amalgamation 2022-09-10 12:03:36 -07:00
fflush.internal.h Make system() and popen() thread safe 2022-10-13 15:54:05 -07:00
fflush_unlocked.c Implement pthread_atfork() 2022-10-16 12:25:13 -07:00
fflushimpl.c Fold LIBC_RAND into LIBC_STDIO/TINYMATH/INTRIN 2022-08-11 12:32:00 -07:00
fgetc.c Remove stdio lock macros from amalgamation 2022-09-10 12:03:36 -07:00
fgetc_unlocked.c Make improvements 2022-05-28 00:28:09 -07:00
fgetln.c Remove stdio lock macros from amalgamation 2022-09-10 12:03:36 -07:00
fgetpos.c Change license 2020-12-27 17:18:44 -08:00
fgets.c Remove stdio lock macros from amalgamation 2022-09-10 12:03:36 -07:00
fgets_unlocked.c Improve cosmo's conformance to libc-test 2022-10-10 17:52:41 -07:00
fgetwc.c Remove stdio lock macros from amalgamation 2022-09-10 12:03:36 -07:00
fgetwc_unlocked.c Make improvements 2022-05-28 00:28:09 -07:00
fgetws.c Remove stdio lock macros from amalgamation 2022-09-10 12:03:36 -07:00
fgetws_unlocked.c Apply even more fixups 2022-06-12 11:57:00 -07:00
fileno.c Remove stdio lock macros from amalgamation 2022-09-10 12:03:36 -07:00
fileno_unlocked.c Refactor some code 2022-05-28 14:09:21 -07:00
flbf.c Work towards improving signals and processes 2021-01-27 19:34:02 -08:00
flockfile.c Make more improvements to threading support 2022-10-09 00:08:47 -07:00
flushlbf.c Remove stdio lock macros from amalgamation 2022-09-10 12:03:36 -07:00
fmemopen.c Make important improvements 2022-09-14 22:39:08 -07:00
fopen.c Restore zip.com and .symtab files 2022-08-21 00:17:20 -07:00
fopenflags.c Fix issues with stdio needed for Lua 2021-03-06 19:04:26 -08:00
fpending.c Work towards improving signals and processes 2021-01-27 19:34:02 -08:00
fprintf.c Remove stdio lock macros from amalgamation 2022-09-10 12:03:36 -07:00
fprintf_unlocked.c Use re-entrant locks on stdio 2022-05-22 08:28:33 -07:00
fpurge.c Add more missing libc functionality 2022-08-06 10:50:51 -07:00
fputc.c Remove stdio lock macros from amalgamation 2022-09-10 12:03:36 -07:00
fputc_unlocked.c Refactor some code 2022-05-28 14:09:21 -07:00
fputs.c Remove stdio lock macros from amalgamation 2022-09-10 12:03:36 -07:00
fputs_unlocked.c Apply even more fixups 2022-06-12 11:57:00 -07:00
fputwc.c Remove stdio lock macros from amalgamation 2022-09-10 12:03:36 -07:00
fputwc_unlocked.c Pay off more technical debt 2022-09-12 23:36:56 -07:00
fputws.c Improve system call wrappers 2022-09-19 15:06:25 -07:00
fputws_unlocked.c Improve system call wrappers 2022-09-19 15:06:25 -07:00
fread.c Fix bugs and make code tinier 2022-10-09 23:21:34 -07:00
fread_unlocked.c Fix bugs and make code tinier 2022-10-09 23:21:34 -07:00
freadable.c Work towards improving signals and processes 2021-01-27 19:34:02 -08:00
freading.c Work towards improving signals and processes 2021-01-27 19:34:02 -08:00
freestrlist.c Pay off more technical debt 2022-09-12 23:36:56 -07:00
freopen.c Remove stdio lock macros from amalgamation 2022-09-10 12:03:36 -07:00
fscanf.c Change license 2020-12-27 17:18:44 -08:00
fseek.c Make major improvements to stdio 2021-03-26 22:31:41 -07:00
fseeko.c Fix bugs and make code tinier 2022-10-09 23:21:34 -07:00
fseeko_unlocked.c Fix bugs and make code tinier 2022-10-09 23:21:34 -07:00
fsetlocking.c Add raw memory visualization tool to redbean 2022-05-14 04:33:58 -07:00
fsetpos.c Change license 2020-12-27 17:18:44 -08:00
ftell.c Make major improvements to stdio 2021-03-26 22:31:41 -07:00
ftello.c Remove stdio lock macros from amalgamation 2022-09-10 12:03:36 -07:00
ftrylockfile.c Make more improvements to threading support 2022-10-09 00:08:47 -07:00
funlockfile.c Make more improvements to threading support 2022-10-09 00:08:47 -07:00
fwritable.c Work towards improving signals and processes 2021-01-27 19:34:02 -08:00
fwrite.c Fix bugs and make code tinier 2022-10-09 23:21:34 -07:00
fwrite_unlocked.c Fix bugs and make code tinier 2022-10-09 23:21:34 -07:00
fwriting.c Work towards improving signals and processes 2021-01-27 19:34:02 -08:00
g_rando.S Fold LIBC_RAND into LIBC_STDIO/TINYMATH/INTRIN 2022-08-11 12:32:00 -07:00
gb18030.inc Add more missing libc functionality 2022-08-06 10:50:51 -07:00
gcvt.c Add pthread attributes and other libc functions 2022-09-07 05:28:32 -07:00
getc.c Make more fixes and improvements 2022-06-13 11:02:13 -07:00
getc_unlocked.c Apply even more fixups 2022-06-12 11:57:00 -07:00
getchar.c Apply even more fixups 2022-06-12 11:57:00 -07:00
getchar_unlocked.c Apply even more fixups 2022-06-12 11:57:00 -07:00
getdelim.c Remove stdio lock macros from amalgamation 2022-09-10 12:03:36 -07:00
getdelim_unlocked.c Unbloat the build 2022-08-11 00:15:29 -07:00
getentropy.c Fold LIBC_RAND into LIBC_STDIO/TINYMATH/INTRIN 2022-08-11 12:32:00 -07:00
getline.c Fix some issues and do some code cleanup 2022-05-23 10:15:53 -07:00
getrandom.c Add some tests for execve() 2022-10-02 14:58:14 -07:00
gets.c Make important improvements 2022-09-14 22:39:08 -07:00
getwc.c Apply even more fixups 2022-06-12 11:57:00 -07:00
getwc_unlocked.c Apply even more fixups 2022-06-12 11:57:00 -07:00
getwchar.c Apply even more fixups 2022-06-12 11:57:00 -07:00
getwchar_unlocked.c Apply even more fixups 2022-06-12 11:57:00 -07:00
hex.internal.h Add function for creating hex string literals 2021-08-07 07:05:19 -07:00
hkscs.inc Add more missing libc functionality 2022-08-06 10:50:51 -07:00
iconv.c Tidy up the threading implementation 2022-09-10 02:56:25 -07:00
iconv.h Add more missing libc functionality 2022-08-06 10:50:51 -07:00
internal.h Fold LIBC_RAND into LIBC_STDIO/TINYMATH/INTRIN 2022-08-11 12:32:00 -07:00
jis0208.inc Add more missing libc functionality 2022-08-06 10:50:51 -07:00
joinstrlist.c Pay off more technical debt 2022-09-12 23:36:56 -07:00
kappendf.c Pay off more technical debt 2022-09-12 23:36:56 -07:00
ksc.inc Add more missing libc functionality 2022-08-06 10:50:51 -07:00
kvappendf.c Fix bugs and make code tinier 2022-10-09 23:21:34 -07:00
lcg.internal.h Fold LIBC_RAND into LIBC_STDIO/TINYMATH/INTRIN 2022-08-11 12:32:00 -07:00
legacychars.inc Add more missing libc functionality 2022-08-06 10:50:51 -07:00
lemur64.c Rename rand64() to _rand64() 2022-10-10 04:12:06 -07:00
lock.internal.h Remove stdio lock macros from amalgamation 2022-09-10 12:03:36 -07:00
mkdtemp.c Rename rand64() to _rand64() 2022-10-10 04:12:06 -07:00
mkostemp.c Change license 2020-12-27 17:18:44 -08:00
mkostemps.c Import C++ Standard Template Library 2022-03-22 06:41:54 -07:00
mkostempsm.c Rename rand64() to _rand64() 2022-10-10 04:12:06 -07:00
mkstemp.c Change license 2020-12-27 17:18:44 -08:00
mkstemps.c Change license 2020-12-27 17:18:44 -08:00
mktemp.c Change license 2020-12-27 17:18:44 -08:00
mt19937.c Fold LIBC_RAND into LIBC_STDIO/TINYMATH/INTRIN 2022-08-11 12:32:00 -07:00
paginate.c Fold LIBC_BITS into LIBC_INTRIN 2022-08-11 12:13:18 -07:00
pclose.c Fix bugs and make code tinier 2022-10-09 23:21:34 -07:00
popen.c Make system() and popen() thread safe 2022-10-13 15:54:05 -07:00
posix_spawn.c Implement pthread_atfork() 2022-10-16 12:25:13 -07:00
posix_spawn.h Revamp posix_spawn() implementation 2022-10-12 05:26:58 -07:00
posix_spawn.internal.h Revamp posix_spawn() implementation 2022-10-12 05:26:58 -07:00
posix_spawn_file_actions.c Revamp posix_spawn() implementation 2022-10-12 05:26:58 -07:00
posix_spawnattr.c Implement pthread_atfork() 2022-10-16 12:25:13 -07:00
posix_spawnp.c Revamp posix_spawn() implementation 2022-10-12 05:26:58 -07:00
printf.c Use re-entrant locks on stdio 2022-05-22 08:28:33 -07:00
putc.c Apply even more fixups 2022-06-12 11:57:00 -07:00
putc_unlocked.c Apply even more fixups 2022-06-12 11:57:00 -07:00
putchar.c Apply even more fixups 2022-06-12 11:57:00 -07:00
putchar_unlocked.c Apply even more fixups 2022-06-12 11:57:00 -07:00
puts.c Remove stdio lock macros from amalgamation 2022-09-10 12:03:36 -07:00
putwc.c Apply even more fixups 2022-06-12 11:57:00 -07:00
putwc_unlocked.c Apply even more fixups 2022-06-12 11:57:00 -07:00
putwchar.c Apply even more fixups 2022-06-12 11:57:00 -07:00
putwchar_unlocked.c Apply even more fixups 2022-06-12 11:57:00 -07:00
rand.c Rename rand64() to _rand64() 2022-10-10 04:12:06 -07:00
rand.h Improve cosmo's conformance to libc-test 2022-10-10 17:52:41 -07:00
random.c Fold LIBC_RAND into LIBC_STDIO/TINYMATH/INTRIN 2022-08-11 12:32:00 -07:00
rdrand.c Rename rand64() to _rand64() 2022-10-10 04:12:06 -07:00
rdrand_init.c Fold LIBC_RAND into LIBC_STDIO/TINYMATH/INTRIN 2022-08-11 12:32:00 -07:00
rdseed.c Rename rand64() to _rand64() 2022-10-10 04:12:06 -07:00
readdir64.S Tidy up the threading implementation 2022-09-10 02:56:25 -07:00
real1.c Fold LIBC_RAND into LIBC_STDIO/TINYMATH/INTRIN 2022-08-11 12:32:00 -07:00
real2.c Fold LIBC_RAND into LIBC_STDIO/TINYMATH/INTRIN 2022-08-11 12:32:00 -07:00
real3.c Fold LIBC_RAND into LIBC_STDIO/TINYMATH/INTRIN 2022-08-11 12:32:00 -07:00
revjis.inc Add more missing libc functionality 2022-08-06 10:50:51 -07:00
rewind.c Improve cosmo's conformance to libc-test 2022-10-10 17:52:41 -07:00
rngset.c Fold LIBC_RAND into LIBC_STDIO/TINYMATH/INTRIN 2022-08-11 12:32:00 -07:00
scandir.c Improve cosmo's conformance to libc-test 2022-10-10 17:52:41 -07:00
scanf.c Change license 2020-12-27 17:18:44 -08:00
setbuf.c Make major improvements to stdio 2021-03-26 22:31:41 -07:00
setbuffer.c Make major improvements to stdio 2021-03-26 22:31:41 -07:00
setlinebuf.c Make major improvements to stdio 2021-03-26 22:31:41 -07:00
setvbuf.c Remove stdio lock macros from amalgamation 2022-09-10 12:03:36 -07:00
sortstrlist.c Simplify redbean serialization code 2022-09-06 20:07:29 -07:00
srand.c Improve cosmo's conformance to libc-test 2022-10-10 17:52:41 -07:00
stdbuf.c Make major improvements to stdio 2021-03-26 22:31:41 -07:00
stderr-init.S Pay off more technical debt 2022-09-12 23:36:56 -07:00
stderr.c Remove more nonstandard stuff from cosmopolitan.h 2021-03-01 00:18:23 -08:00
stdin-init.S Pay off more technical debt 2022-09-12 23:36:56 -07:00
stdin.c Remove more nonstandard stuff from cosmopolitan.h 2021-03-01 00:18:23 -08:00
stdio.h Further improve cocmd interpreter 2022-10-12 10:44:54 -07:00
stdio.mk Revamp posix_spawn() implementation 2022-10-12 05:26:58 -07:00
stdio_ext.h Make some foss compatibility improvements 2022-10-14 13:59:34 -07:00
stdout-init.S Pay off more technical debt 2022-09-12 23:36:56 -07:00
stdout.c Fold LIBC_BITS into LIBC_INTRIN 2022-08-11 12:13:18 -07:00
strfry.c Fold LIBC_ALG into LIBC_MEM 2022-08-13 08:32:34 -07:00
strlist.internal.h Simplify redbean serialization code 2022-09-06 20:07:29 -07:00
system.c Make system() and popen() thread safe 2022-10-13 15:54:05 -07:00
temp.h Add more missing libc functionality 2022-08-06 10:50:51 -07:00
tmpfile.c Fix some bugs 2022-08-14 13:28:07 -07:00
ungetc.c Remove stdio lock macros from amalgamation 2022-09-10 12:03:36 -07:00
ungetc_unlocked.c Apply even more fixups 2022-06-12 11:57:00 -07:00
ungetwc.c Remove stdio lock macros from amalgamation 2022-09-10 12:03:36 -07:00
ungetwc_unlocked.c Pay off more technical debt 2022-09-12 23:36:56 -07:00
vappendf.c Fix bugs and make code tinier 2022-10-09 23:21:34 -07:00
versionsort.c Improve cosmo's conformance to libc-test 2022-10-10 17:52:41 -07:00
vfprintf.c Remove stdio lock macros from amalgamation 2022-09-10 12:03:36 -07:00
vfprintf_unlocked.c Use re-entrant locks on stdio 2022-05-22 08:28:33 -07:00
vfscanf.c Change license 2020-12-27 17:18:44 -08:00
vigna.c Rename rand64() to _rand64() 2022-10-10 04:12:06 -07:00
vprintf.c Use re-entrant locks on stdio 2022-05-22 08:28:33 -07:00
vscanf.c Change license 2020-12-27 17:18:44 -08:00
xorshift.h Fold LIBC_RAND into LIBC_STDIO/TINYMATH/INTRIN 2022-08-11 12:32:00 -07:00
xorshift32.c Fold LIBC_RAND into LIBC_STDIO/TINYMATH/INTRIN 2022-08-11 12:32:00 -07:00
xorshift64.c Fold LIBC_RAND into LIBC_STDIO/TINYMATH/INTRIN 2022-08-11 12:32:00 -07:00