Closed wimstockman closed 3 years ago
Hi Wim, I don't understand why you don't pass the filename of the output file to your program with a command argument?
For example ./finalcutdemo -o output.file
The ">" creates an I/O redirection that prevents that FINAL CUT works correctly with the terminal/tty. This prevents that core functions like the terminal detection works!
Here is a small example with a shell script:
$ cat is-tty.sh
#!/bin/sh
if [ -t 1 ]
then
echo "STDOUT is attached to TTY"
fi
if [ -p /dev/stdout ]
then
echo "STDOUT is attached to a pipe"
fi
if [ ! -t 1 ] && [ ! -p /dev/stdout ]
then
echo "STDOUT is attached to a redirection"
fi
$ ./is-tty.sh
STDOUT is attached to TTY
$ ./is-tty.sh | cat >/dev/tty
STDOUT is attached to a pipe
$ ./is-tty.sh >file.txt ; cat file.txt
STDOUT is attached to a redirection
I hope you see where the problem is?
This may not be the answer you had expected, but it makes no sense to work against the default behavior of the system.
Hi Markus,
Thanks for your answer. I found the solution: int stdoutBack = dup(1); close(1); int output = open("/dev/tty",O_RDWR); init(argc,argv,vector); // Here I start the finalcut program dup2(stdoutBack,1);
When I finish my little demo I will sent it to you so you can see why I needed it for :-)
Kind regards, Wim
Closed because of inactivity.
Hi, it's me again. Thanks again for resolving the std::cin problem. But now I have the following problem if I do : finalcutdemo > file.txt I don't see my finalcut window appear. if I close the stdout like with the stdinput I see my finalcut program. but I cannot get the output the be written to the file.txt. I should be able to reattach the stdoutput. Or to make only the finalcut windows appear to tty. Do you have an idea ?
kind regard, Wim Stockman