Question: I have a simple C/CPP process running on a linux system. This is a.out.

Another process is capable to start a.out inside its code. This is b.out.

What code do I need inside a.out to understand that it is executed from the command line?
Eg ./a.out

Is there a way a process to know if it started from the cmd or started from another process?

Answer: 
I would set an environment variable, in the parent process, to some value (say the parent pid), and have the child process check for it.

It is unlikely that a shell user would set this variable (call it something unlikely to name-clash), so if this variable is set to the expected value, then you know that it is being started from the parent process.
You can check whether its standard input is a terminal:

```
if(isatty(0)) { ... }

```