Are file descriptors unique across a process, or throughout the whole system. Because every file seems the use the same descriptor for stdin and stdout. Is there something special with these? How does stdin and stdout work?
In a C program I want to run a Python interactive loop that takes its input from and makes its output to a pseudo terminal (for example pts/4) different than the one from which the C program was launched (for example pts/1).
The basic way to run an interactive loop is:
PyRun_InteractiveLoop(stdin, "<stdin>");
This however does not solve the problem because it uses the pseudo terminal fro
Usually log messages are written to stderr. I'm wondering if it is a good idea/practice to split log messages so that errors and warnings go to stderr while debug/informational/notice messages go to stdout instead?
I have a C program that continously outputs info to stdout. The problem is that I am redirecting the stdout and stderr to a file and stdout is written at the end of the problem rather than continously to the file. This could be a problem if for example the program is killed and the stdout output is lost.
My program is invoked by another process, and communicates with it via stdin and stdout. I want to interact with my program via a command line interface, but obviously the usual method of just running it in a terminal doesn't work. I'm looking for the simplest possible way of achieving this.
My program is currently written in Lua, but might become C or something else.
I'm trying to write to stdin and read from stdout ( and stderr ) from an external program, without changing the code.
I've tried using named pipes, but stdout doesn't show until the program is terminated and stdin only works on the first input( then cin is null ).
i've tried using /proc/[pid]/fd but that only writes and reads from the terminal and not the program.
I have the following code:
pid_t pid = fork();
if (pid == -1)
{
// ...
}
else if (pid == 0)
{
stdin = someopenfile;
stdout = someotherfile;
stderr = somethirdopenfile;
execvp(args[0], args);
// handle error ...
}
else
{
// ...
}
The problem is, the input/output of the execvp() call is still the console, rather than the files.
I am trying to understand how to use the stdout as the stdin of another command. To test it, I am trying to use the following command to delete all directories from the current folder.
ls -d -- */ | rm -rf $1
I would expect the result of ls -d -- */ to be piped into the input of the rm, but it does not work. Ideas?
I need to monitor a screen session in real time using a Python script. It needs to know when the display changes. I believe this can be described as whenever stdout is flushed, or a character is entered to stdin.