I am working with a shared library that is being called through the ctypes module. I would like to redirect the stdout associated with this module to a variable or a file t
Simplest example, because this question in google top.
import os from ctypes import CDLL libc = CDLL(None) stdout = os.dup(1) silent = os.open(os.devnull, os.O_WRONLY) os.dup2(silent, 1) libc.printf(b"Hate this text") os.dup2(stdout, 1)