popen()considerable grief, such as single quotes, quoted strings etc. Passing these constructs successfully through shell interpretation presents pitfalls. (One can do it by replacing any single quotes by the sequence single-quote backslash single-quote single-quote, then surrounding the entire address with single quotes. Ugly, huh?)
Some of this unpleasantness can be avoided by eschewing the use of
popen(), and resorting to
exec()directly. This is sometimes necessary in any event; for example, user-installed handlers for SIGCHLD will usually break
pclose()to a greater or lesser extent.
Here's an example:
/* #include <paths.h> if you have it */
#define _PATH_SENDMAIL "/usr/lib/sendmail"
To Look for similar posts on File handling in Linux explore the following links from the same blog as well.