2 questions:
1) Is there any Linux/Posix API to know if a process has been invoked as a background process?
linux> myprogram &
A process is in the background if its parent shell process isn't suspended (waiting), which you can check through the PID.
To put a process in the background (detach it completely from the shell at runtime), you use the daemon(3) function.