writing a dup2 function
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > writing a dup2 function




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    writing a dup2 function  
Ash


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10:36 PM

Can somebody tell me how we can write an equivalent of  dup2()
function without using fcntl function?





[ Post a follow-up to this message ]



    Re: writing a dup2 function  
Barry Margolin


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10:36 PM

In article <60aab6b4.0401192254.6b4132ed@posting.google.com>,
amujoo@yahoo.com (Ash) wrote:
quote:
> Can somebody tell me how we can write an equivalent of dup2() > function without using fcntl function?
Close the target FD, then call dup() repeatedly until it returns that FD. Then go back and close all the other FDs that were opened in the loop (so you'll have to keep a list of them as you go). -- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me ***




[ Post a follow-up to this message ]



    Re: writing a dup2 function  
examnotes


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10:36 PM

Barry Margolin <barmar@alum.mit.edu> writes:
quote:
> In article <60aab6b4.0401192254.6b4132ed@posting.google.com>, > amujoo@yahoo.com (Ash) wrote: > > > Close the target FD, then call dup() repeatedly until it returns that > FD. Then go back and close all the other FDs that were opened in the > loop (so you'll have to keep a list of them as you go).
That's not exactly equivalent. dup2() is atomic, i.e. there is no instant where the target fd is invalid. -- Måns Rullgård mru@kth.se




[ Post a follow-up to this message ]



    Re: writing a dup2 function  
Barry Margolin


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10:36 PM

In article <yw1xwu7now5w.fsf@ford.guide>, mru@kth.se (Måns Rullgård)
wrote:
quote:
> Barry Margolin <barmar@alum.mit.edu> writes: > > > That's not exactly equivalent. dup2() is atomic, i.e. there is no > instant where the target fd is invalid.
OK. If the process is multi-threaded, it needs to disable thread switching first. -- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me ***




[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 01:22 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register