Python os.dup and side-effects
At the beginning of my python script I do:

    if '-' in args:
      fd = os.fdopen(os.dup(0))
      sys.stderr.write(fd.read())
      fd.close()

I thought that this wouldn't affect the behavior of the rest of my program but it seems to, i.e. if I comment out these 4 lines my code works but if they are executed then my program has unexpected results (which I'm having difficulty troubleshooting).

Am I using os.dup incorrectly?

Thanks.
  
Python os.dup and side-effects
===

At the beginning of my python script I do:

    if '-' in args:
      fd = os.fdopen(os.dup(0))
      sys.stderr.write(fd.read())
      fd.close()

I thought that this wouldn't affect the behavior of the rest of my program but it seems to, i.e. if I comment out these 4 lines my code works but if they are executed then my program has unexpected results (which I'm having difficulty troubleshooting).

Am I using os.dup incorrectly?

Thanks.
  