05-23-2007
1. Use one descriptor opened read/write and use it for stdin/stdout/stderr rather than opening twice.
as in the single "open(con,O_RDWR)"
2, try using write and read to confirm input/output before using the stdio APIs.
3. Also, check that you actually need the dup2s, as you have already done close(0/1/2)
try
fd=open(con,O_RDWR);
dup2(1,fd);
dup2(2,fd);
9 More Discussions You Might Find Interesting
1. SCO
Hi,
can someone pls help resolves this problem.
I have an Openserver 5.0.4 running but had this error after having a power failure problem.
error: cannot access termainl control database entry
I have a arnetport also install with wyse 60 terminals, non of the users can have access on... (2 Replies)
Discussion started by: kayode
2 Replies
2. Shell Programming and Scripting
I call "rsh -l username HOSTMANE myscript.sh" from the script on TRU64 OSF1 cluster. The myscript.sh does some logic one the different cluster node
and output requested info on my terminal.
If I try to use commands to control output (clear, tput etc..) it just does not work. Obviously the rsh... (2 Replies)
Discussion started by: zam
2 Replies
3. UNIX for Advanced & Expert Users
I pressed CTRL Z and suspended the job. then I pressed bg, The process re-started to throw output on the terminal and its not allowing me to access the prompt.
its not even accepting CTRL Z. The process has been running for about 2 hours now and I want to suspend it by opening another terminal.... (3 Replies)
Discussion started by: rakeshou
3 Replies
4. Shell Programming and Scripting
Hey
First of all: I'm on a Mac. I'm quite new to this, so forgive me if i sound like a newb :-)
I wish to install the Deluge BitTorrent client. First of all I installed Macports and made it run smooth. But then I ran into a problem when I should install Deluge. I can post the log, and maybe... (4 Replies)
Discussion started by: Sixmax
4 Replies
5. OS X (Apple)
hi, i am on a quest to access and even mount if possible a drive on os x. there is no driver for the device, but it lists fine in the system profiler. can i access its location from the terminal? how? here is what i get on the system profiler:
Speed: Up to 480 Mb/sec
Manufacturer: SAMSUNG
... (3 Replies)
Discussion started by: sontarieh
3 Replies
6. What is on Your Mind?
My auntie told me that she has been suspecting that her little kids are looking at some "illegal" sites online. She put a free web blocker on the computer, but they might be finding loopholes. She wanna install some child-control program to see what's going on. There are so many since I searched... (5 Replies)
Discussion started by: Bluerosen
5 Replies
7. Fedora
hi all,
I open Matlab program from terminal. However, when I go back to terminal I can't do anything in it , only until Matlab is closed.
Can someone please advise me on how I can oversome this problem ?
thanks
peter (2 Replies)
Discussion started by: peter_071
2 Replies
8. Slackware
Hello everybody,
I'm testing some aspects of X Terminal implementation and it's going great. I can use remote applications on my local slow workstation at remote's processor speed by redirecting the remote DISPLAY variable to "my_local_ip:0.0"; but i'm having troubles to get remote audio and... (2 Replies)
Discussion started by: semash!
2 Replies
9. Shell Programming and Scripting
Hi All,
My program flow is as below
Windows batch -- > Cygwin batch --> zsh script
There are multiple Cygwin batch scripts that are called from Windows batch file . But when i am executing the first cygwin batch script the control goes to the zsh file and executes and stoping from... (1 Reply)
Discussion started by: Hypesslearner
1 Replies
dup2(3C) Standard C Library Functions dup2(3C)
NAME
dup2 - duplicate an open file descriptor
SYNOPSIS
#include <unistd.h>
int dup2(int fildes, int fildes2);
DESCRIPTION
The dup2() function causes the file descriptor fildes2 to refer to the same file as fildes. The fildes argument is a file descriptor refer-
ring to an open file, and fildes2 is a non-negative integer less than the current value for the maximum number of open file descriptors
allowed the calling process. See getrlimit(2). If fildes2 already refers to an open file, not fildes, it is closed first. If fildes2
refers to fildes, or if fildes is not a valid open file descriptor, fildes2 will not be closed first.
The dup2() function is equivalent to fcntl(fildes, F_DUP2FD, fildes2).
RETURN VALUES
Upon successful completion a non-negative integer representing the file descriptor is returned. Otherwise, -1 is returned and errno is set
to indicate the error.
ERRORS
The dup2() function will fail if:
EBADF The fildes argument is not a valid open file descriptor.
EBADF The files2 argument is negative or is not less than the current resource limit returned by getrlimit(RLIMIT_NOFILE, ...).
EINTR A signal was caught during the dup2() call.
EMFILE The process has too many open files. See fcntl(2).
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
|MT-Level |Async-Signal-Safe |
+-----------------------------+-----------------------------+
SEE ALSO
close(2), creat(2), exec(2), fcntl(2), getrlimit(2), open(2), pipe(2), lockf(3C), attributes(5), standards(5)
SunOS 5.10 19 Dec 2003 dup2(3C)