Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 7 Nov 1997 01:31:26 +0100 (CET)
From:      tege@pdc.kth.se
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   bin/4961: Problems with fseek and fprints
Message-ID:  <199711070031.BAA12795@pro.tmg.se>
Resent-Message-ID: <199711070040.QAA25297@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         4961
>Category:       bin
>Synopsis:       Problems with fseek and fprints
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Nov  6 16:40:01 PST 1997
>Last-Modified:
>Originator:     Torbjorn Granlund
>Organization:
TMG Datakonsult
>Release:        FreeBSD 2.2.2-RELEASE i386
>Environment:

Quite likely irrelevant.  (Reproducible on radically different
configurations.)

>Description:

1) fseek is ignored on files that were fdopen'ed in append mode.
2) The second fprintf below sets errno even while no error really
   happens.  Note that this incorrect behaviour happens even if
   the fseek belowcall of the test case is removed.

>How-To-Repeat:

Compile the test case below.
Then run it and redirect its output to a file.
I think it should print "errno should be zero here: 0".
But it prints "This should be overwritten;errno should be zero here: 2".

#include <unistd.h>
#include <stdio.h>
extern int errno;
main ()
{ FILE *fs;
  fs = fdopen (dup (fileno (stdout)), "a");
  fprintf (fs, "This should be overwritten;");
  fseek (fs, 0L, SEEK_SET);
  fprintf (fs, "errno should be zero here: %d\n", errno);
  exit (0); }


>Fix:

>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199711070031.BAA12795>