public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/29601] New: fclose() doesn't flush the output as it should be
@ 2022-09-22 14:51 abdulrahman.mahmoud75 at gmail dot com
  2022-09-22 16:05 ` [Bug libc/29601] " schwab@linux-m68k.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: abdulrahman.mahmoud75 at gmail dot com @ 2022-09-22 14:51 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=29601

            Bug ID: 29601
           Summary: fclose() doesn't flush the output as it should be
           Product: glibc
           Version: 2.28
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: abdulrahman.mahmoud75 at gmail dot com
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

I have created a mini example to test the fgets() utility but when i run this
example i don't see any output in the shell, below is my example:

#include <stdio.h>

int main () {
   FILE *fp, *fd_3, *fd_2;
   char str[60];
   char str1[] = "writing to file ";
   char str2[] = "my file";

   fp = fopen("file/test_fopen" , "w");
   fclose(fp);
   fd_3 = fopen("file/test_fopen" , "r");
   fp = fopen("file/test_fopen" , "a");
   fwrite(str1 , 1 , sizeof(str1) , fp);
   if( fgets (str, 60, fd_3)!=NULL ) {
      puts(str);
   }
   fclose(fp);
   fd_2 = fopen("file/test_fopen" , "a");
   fwrite(str2 , 1 , sizeof(str2) , fd_2);
   if( fgets (str, 60, fd_3)!=NULL ) {
      puts(str);
   }
   fclose(fd_2);

   return(0);
}

When i compile and run this code against glibc-2.17 i receive an output
"writing to file" on the shell but when i compile against glibc-2.28, there is
no output.

So is this an expected behavior? is the way of flushing when calling fclose()
changed between the two versions?

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libc/29601] fclose() doesn't flush the output as it should be
  2022-09-22 14:51 [Bug libc/29601] New: fclose() doesn't flush the output as it should be abdulrahman.mahmoud75 at gmail dot com
@ 2022-09-22 16:05 ` schwab@linux-m68k.org
  2022-09-22 18:01 ` abdulrahman.mahmoud75 at gmail dot com
  2022-09-23  5:25 ` [Bug stdio/29601] " fweimer at redhat dot com
  2 siblings, 0 replies; 4+ messages in thread
From: schwab@linux-m68k.org @ 2022-09-22 16:05 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=29601

--- Comment #1 from Andreas Schwab <schwab@linux-m68k.org> ---
This is because EOF is now sticky, see commit 2cc7bad0ae.  You need to call
fseek or clearerr before you can read more from a changing file.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libc/29601] fclose() doesn't flush the output as it should be
  2022-09-22 14:51 [Bug libc/29601] New: fclose() doesn't flush the output as it should be abdulrahman.mahmoud75 at gmail dot com
  2022-09-22 16:05 ` [Bug libc/29601] " schwab@linux-m68k.org
@ 2022-09-22 18:01 ` abdulrahman.mahmoud75 at gmail dot com
  2022-09-23  5:25 ` [Bug stdio/29601] " fweimer at redhat dot com
  2 siblings, 0 replies; 4+ messages in thread
From: abdulrahman.mahmoud75 at gmail dot com @ 2022-09-22 18:01 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=29601

--- Comment #2 from abdulrahman mahmoud <abdulrahman.mahmoud75 at gmail dot com> ---
(In reply to Andreas Schwab from comment #1)
> This is because EOF is now sticky, see commit 2cc7bad0ae.  You need to call
> fseek or clearerr before you can read more from a changing file.

Thanks Andreas, i have called clearerr and it solved the issue.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug stdio/29601] fclose() doesn't flush the output as it should be
  2022-09-22 14:51 [Bug libc/29601] New: fclose() doesn't flush the output as it should be abdulrahman.mahmoud75 at gmail dot com
  2022-09-22 16:05 ` [Bug libc/29601] " schwab@linux-m68k.org
  2022-09-22 18:01 ` abdulrahman.mahmoud75 at gmail dot com
@ 2022-09-23  5:25 ` fweimer at redhat dot com
  2 siblings, 0 replies; 4+ messages in thread
From: fweimer at redhat dot com @ 2022-09-23  5:25 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=29601

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |fweimer at redhat dot com
          Component|libc                        |stdio
           See Also|                            |https://sourceware.org/bugz
                   |                            |illa/show_bug.cgi?id=1190
              Flags|                            |security-

--- Comment #3 from Florian Weimer <fweimer at redhat dot com> ---
Closing per comment 1 and comment 2.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-09-23  5:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-22 14:51 [Bug libc/29601] New: fclose() doesn't flush the output as it should be abdulrahman.mahmoud75 at gmail dot com
2022-09-22 16:05 ` [Bug libc/29601] " schwab@linux-m68k.org
2022-09-22 18:01 ` abdulrahman.mahmoud75 at gmail dot com
2022-09-23  5:25 ` [Bug stdio/29601] " fweimer at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).