Hacker News new | ask | show | jobs
by mr_mitm 775 days ago
How could curl detect where it's piped to?
2 comments

Something like (in Python)

os.isatty(sys.stdout.fileno())

That doesn't say where it's piped though. It could be redirected to a file, or piped to something harmless like jq.
Iterate through /proc/<pid>/fd and check for the pipe id in the symlink target.