create backup file descriptor?

Posted by BobTurbo on Stack Overflow See other posts from Stack Overflow or by BobTurbo
Published on 2010-05-06T10:24:47Z Indexed on 2010/05/06 10:28 UTC
Read the original article Hit count: 165

Filed under:
|
  stdinBackup = 4;
  dup2(0, stdinBackup);

Currently I am doing the above to 'backup' stdin so that it can be restored from backup later after it has been redirected somewhere else. I have a feeling that I am doing a lot wrong? (eg arbitrarily assigning 4 is surely not right). Anyone point me in the right direction?

© Stack Overflow or respective owner

Related posts about unix

Related posts about c