Getting output from another program.
Today I discovered the 'file' command. I was immediately embarrassed and upset that I have gone so long without ever running into it. It also made me think of a few questions.
1. Is there a C library that provides equivalent or similar functionality (especially for identifying MIME types)?
2. What's the best practice for getting output from an external command? I've heard of it being done by forking, overwriting the child's file
descriptors for stdin and stdout with pipes, and then exec'ing the command.
Signature · 3 lines
Topher Fischer GnuPG Fingerprint: 3597 1B8D C7A5 C5AF 2E19 EFF5 2FC3 BE99 D123 6674 [email protected]
Quoted 2 lines · Topher Fischer
1. Is there a C library that provides equivalent or similar functionality (especially for identifying MIME types)?
libmagic (part of 'file' package)
libgmime (part of 'gmime' package)
Leslie
Signature · 2 lines
NEW homepage: https://viridian.dnsalias.net/~sky/homepage/ gpg --keyserver pgp.mit.edu --recv-keys DD4EBF83
Quoted 5 lines · Topher Fischer
2. What's the best practice for getting output from an external command? I've heard of it being done by forking, overwriting the child's file
descriptors for stdin and stdout with pipes, and then exec'ing the command.
have you checked popen?
-M