FD(4) BSD Kernel Interfaces Manual FD(4)NAME
fd, stdin, stdout, stderr -- file descriptor files
DESCRIPTION
The files /dev/fd/0 through /dev/fd/# refer to file descriptors which can be accessed through the file system. If the file descriptor is
open and the mode the file is being opened with is a subset of the mode of the existing descriptor, the call:
fd = open("/dev/fd/0", mode);
and the call:
fd = fcntl(0, F_DUPFD, 0);
are equivalent.
Opening the files /dev/stdin, /dev/stdout and /dev/stderr is equivalent to the following calls:
fd = fcntl(STDIN_FILENO, F_DUPFD, 0);
fd = fcntl(STDOUT_FILENO, F_DUPFD, 0);
fd = fcntl(STDERR_FILENO, F_DUPFD, 0);
Flags to the open(2) call other than O_RDONLY, O_WRONLY and O_RDWR are ignored.
FILES
/dev/fd/#
/dev/stdin
/dev/stdout
/dev/stderr
SEE ALSO tty(4)BSD June 9, 1993 BSD
Check Out this Related Man Page
FD(4) BSD Kernel Interfaces Manual FD(4)NAME
fd, stdin, stdout, stderr -- file descriptor files
DESCRIPTION
The files /dev/fd/0 through /dev/fd/# refer to file descriptors which can be accessed through the file system. If the file descriptor is
open and the mode the file is being opened with is a subset of the mode of the existing descriptor, the call:
fd = open("/dev/fd/0", mode);
and the call:
fd = fcntl(0, F_DUPFD, 0);
are equivalent.
Opening the files /dev/stdin, /dev/stdout and /dev/stderr is equivalent to the following calls:
fd = fcntl(STDIN_FILENO, F_DUPFD, 0);
fd = fcntl(STDOUT_FILENO, F_DUPFD, 0);
fd = fcntl(STDERR_FILENO, F_DUPFD, 0);
Flags to the open(2) call other than O_RDONLY, O_WRONLY and O_RDWR are ignored.
IMPLEMENTATION NOTES
By default, /dev/fd is provided by devfs(5), which provides nodes for the first three file descriptors. Some sites may require nodes for
additional file descriptors; these can be made available by mounting fdescfs(5) on /dev/fd.
FILES
/dev/fd/#
/dev/stdin
/dev/stdout
/dev/stderr
SEE ALSO tty(4), devfs(5), fdescfs(5)BSD June 9, 1993 BSD
PROGRAM A <-> PROGRAM B
PROGRAM A sends data as STDIN ro PROGRAM B and when PROGRAM B is executed from PROGRAM A, it sends output back to PROGRAM A. This is implemented using 2 pipes (fd1 & fd2).
The above process happens in a loop and during the second run, the previous data that had been... (10 Replies)
Hi all
I've run into a snag in a program of mine where part of what I entered in at the start of run-time, instead of the current value within printf() is being printed out.
After failing with fflush() and setbuf(), I tried the following approach
void BufferFlusher()
{
int in=0;... (9 Replies)
I am unable to use STDIn redirection with < (commands)
When I do the following, both approaches work and give the same results:
1.
$ printf "aaa\nbbb\n" > file1
$ printf "111\n222\n" > file2
$ cat file1 file2
aaa
bbb
111
2222.
$ cat <(printf "aaa\nbbb\n") <(printf "111\n222\n")
aaa... (8 Replies)
what would happen if a process wrote to its own stdin?
#include<unistd.h>
#include<fcntl.h>
int main()
{
if((write(STDIN_FILENO,"arrgh!",6))==-1)
{
perror("error writing to file");
}
}
output:
$ gcc temp.c
$ ./a.out
arrgh!$ (9 Replies)
Hi,
i know how to
a) redirect stdout and stderr to one file,
b) and write to two files concurrently with same output using tee command
Now, i want to do both the above together.
I have a script and it should write both stdout and stderr in one file and also write the same content to... (8 Replies)
All,
Ok...so I know I *should* be able to control a process's stdin and stdout from the parent by creating pipes and then dup'ing them in the child. And, this works with all "normal" programs that I've tried. Unfortunately, I want to intercept the stdin/out of the scp application and it seems... (9 Replies)
Hello everybody,
I need some help here. I have a log file that gets updated every hour approximately.
I want to make some processing on each line which is added in the log file with a program written in PERL.
The problem is that I don't see anything when a line is added in the log file.
I... (6 Replies)
Hello,
I am currently interning at a place and my job is to essentially learn UNIX. My supervisor gives me problems here and there to help guide me with my learning but for the most part I'm doing this all by self-teaching myself. Needless to say I have run into a few obstacles...for... (12 Replies)
Hi
Im trying to do the following:
grep -H Date: out/* | sed 's/':'/ /' | awk '$4 ~ /^/ {print $1}' | while read VARIABLE; do
awk '{print $1,$3,$2}' $VARIABLE | sed (take stdin and replace a string in $VARIABLE)
done
What this is basically doing is finding all files with Date: in... (11 Replies)
on linux systems, i can do something like this:
$ JIOO=hello.one.two
$
$ awk -F"." '{print $2}' <<< "${JIOO}"
however, on older systems or other unix systems that dont have the fancy stuff this does not work.
i contemplated using "-v var="${JIOO}" but i dont think that works.
any... (7 Replies)
Hi there,
I need to execute a command in the bash. The program prints some standard (output and) error and then wants the user to choose one of several options and type the according input. I am trying to solve this issue in a bash script but also running into some circular dependency. How can I... (7 Replies)
Hello scripting geniusii! I come to kneel before the alter of your wisdom!
I am looking to take a keyword and replace characters within that keyword and add them to a string variable. I would like this to only go through however many characters the word has, which may vary in size.
... (10 Replies)