https://bugs.kde.org/show_bug.cgi?id=493433

Mark Wielaard <m...@klomp.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|REPORTED                    |CONFIRMED

--- Comment #1 from Mark Wielaard <m...@klomp.org> ---
This new mode (--track-fds=new ?) would help catch issues like the following:

#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>

int
main ()
{
  int oldfd = open ("foobar.txt", O_RDWR|O_CREAT, S_IRUSR | S_IWUSR);
  printf ("got foobar.txt as: %d\n", oldfd);
  /*... do something with oldfd ...*/
  close (oldfd);

  /* Lets open another file... */
  int newfd = open ("foobad.txt", O_RDWR|O_CREAT, S_IRUSR | S_IWUSR);
  printf ("got foobad.txt as: %d\n", newfd);
  /* ... oops we are using the wrong fd (but same number...) */
  dprintf (oldfd, "some new text\n");

  close (newfd);
  return 0;
}

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to