Opened 19 years ago
Closed 19 years ago
#58 closed defect (fixed)
libc: closed standard handles cause uninitialized stdout/stdin/stderr streams
Reported by: | bird | Owned by: | bird |
---|---|---|---|
Priority: | high | Milestone: | libc-0.6.1 |
Component: | baselayout | Version: | 0.6 |
Severity: | major | Keywords: | libc stdout stdin stderr fclose fflush |
Cc: |
Description
smoketests/fclose-1.c exhibit a problem where the parent closes one or more of the standard handles before spawning a child or execing. The child will then end up with an the stream for those handles uninitialized, and any attempt to use them will panic libc.
Change History (2)
comment:1 by , 19 years ago
comment:2 by , 19 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
The stdin/stdout/stderr streams should apparently always be initialized as opened. GLIBC will perform one failing fclose, and the subseqent ones failing because the stream is closed. BSD will fail in the same way all the way. This is in a child which was created with a closed, let say stdout.
If you do fclose(stdout) twice, BSD will crash, while GLIBC & LIBC will fail because it's already closed (no errno) as for 2+ fclose above.
(This problem was found with the coreutils tests/misc testcases.)
fclose-2 is a better testcase. It also shows that fclose() isn't returning the correct error code.