How can my program detect how it was started: by someone using the command-line or by another process?

The program has an optional interactive part that I want to suppress when it was started by another process - running in the background; but when it was started from a terminal I want it to do the interactive bit.

[edit] If it is possible to do from a C++ program.