Redirecting low-api stdout to C

Is there a way to redirect stdout from a low level API ... did not find a function or way to do this ....

+3
source share
4 answers

The system call dupshould allow you to redirect stdout, as shown in this example .

freopenwill also work if you are redirected to a file, but dupcan also be used with handsets and sockets.

+3
source

I believe that dup2 (fd, 1) does the trick, for example. after opening fd with open ().

+3
source

freopen(), .

+1

You can use freopen()to redirect stdout to a file. If you are using a posix-like system, you can use close(), dup()and open()although they work with file descriptors, not files.

+1
source

Source: https://habr.com/ru/post/1755072/


All Articles