Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 01-05-2013, 02:06 PM   #1
Anand Singh
LQ Newbie
Registered: Jan 2013
Posts: 1

Rep: Reputation: Disabled
how to emulate dup2() system call

I want to emulate dup2 without using fcntl. can anybody help me?

Old 01-06-2013, 01:46 AM   #2
Senior Member
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 3,054

Rep: Reputation: 883Reputation: 883Reputation: 883Reputation: 883Reputation: 883Reputation: 883Reputation: 883
Give some context: if you want dup2, why don't you use dup2?
Old 01-06-2013, 03:59 PM   #3
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,678

Rep: Reputation: 1258Reputation: 1258Reputation: 1258Reputation: 1258Reputation: 1258Reputation: 1258Reputation: 1258Reputation: 1258Reputation: 1258
Originally Posted by Anand Singh View Post
I want to emulate dup2 without using fcntl. can anybody help me?

At a fundamental level, you can't. It is a system call that duplicates a file descriptor which is a kernel data structure. The file descriptor returned to a user process is nothing but an index into the kernel table - so "emulation" doesn't exist.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
may i know details about system call how to use system call and definition for virtua mahi rajee Programming 1 05-02-2012 07:45 AM
how to write a system call which returns current system time using call by reference mukul2kul4 Debian 2 09-25-2011 11:17 PM
calling a system call inside a system call suresh.j Linux - Kernel 1 08-03-2010 09:28 PM
Emulate "dup2()" without using "fcntl()" bit128_linux Linux - General 0 03-12-2008 11:12 AM
How can i make centos 4.5's system call using vDSO(call *%gs:0x10) instead of int80 tclwp Red Hat 3 08-06-2007 12:07 AM

All times are GMT -5. The time now is 12:40 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration