Re: freopen() broken in Fedora 15

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jun 9, 2011 at 22:48, Chuck Forsberg WA7KGX N2469R <caf@xxxxxxxx> wrote:
> The standard IO freopen function stopped working on or about
> the time I installed 64 bit Fedora 15 on the omen.com server.
>
> The attached program is derived from the 1977 Bill Joy version.
> It does not display any text when compiled and run under 64 bit
> F 15 clean install and updated as of today.
>
> The workaround is to rewrite the program to eliminate the use
> of freopen.

Looking at an strace is interesting:

Working RHEL-4 (ancietn I know)


close(0)                                = 0
close(0)                                = -1 EBADF (Bad file descriptor)
open("oldhead.c", O_RDONLY)             = 0
fstat64(0, {st_mode=S_IFREG|0664, st_size=1867, ...}) = 0
fstat64(0, {st_mode=S_IFREG|0664, st_size=1867, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0xb7f66000
read(0, "#ifndef\tlint\nstatic char *sccsid"..., 4096) = 1867
write(1, "#ifndef\tlint\n", 13#ifndef	lint
)         = 13
exit_group(0)                           = ?


Not working F15

close(0)                                = 0
open("oldhead.c", O_RDONLY)             = 0
dup3(0, 0, 0)                           = -1 EINVAL (Invalid argument)
close(0)                                = 0
fstat(0, 0x7fff53f398a0)                = -1 EBADF (Bad file descriptor)
fstat(0, 0x7fff53f376f0)                = -1 EBADF (Bad file descriptor)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0x7fdac28e2000
read(0, 0x7fdac28e2000, 8192)           = -1 EBADF (Bad file descriptor)
write(1, "\n", 1
)                       = 1

so it looks like the ordering is off.
1) In the working, it closes(0) twice then opens the file.

2) In the F15, it closes(0), opens file to 0, then closes0) and then
the accesses afterwords don't work.

So commenting out the close(0) that is explicite in the code makes it
work. So somehow code is not running in the order it is expected.

> --
> Chuck Forsberg WA7KGX N2469R     caf@xxxxxxxx   www.omen.com
> Developer of Industrial ZMODEM(Tm) for Embedded Applications
>  Omen Technology Inc      "The High Reliability Software"
> 10255 NW Old Cornelius Pass Portland OR 97231   503-614-0430
>
>
> --
> test mailing list
> test@xxxxxxxxxxxxxxxxxxxxxxx
> To unsubscribe:
> https://admin.fedoraproject.org/mailman/listinfo/test
>



-- 
Stephen J Smoogen.
"The core skill of innovators is error recovery, not failure avoidance."
Randy Nelson, President of Pixar University.
"Let us be kind, one to another, for most of us are fighting a hard
battle." -- Ian MacLaren
-- 
test mailing list
test@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe: 
https://admin.fedoraproject.org/mailman/listinfo/test



[Index of Archives]     [Fedora Desktop]     [Fedora SELinux]     [Photo Sharing]     [Yosemite Forum]     [KDE Users]

  Powered by Linux