Sree said:
hello friends,
Can i make a C program run as as background service?
for eg. like the windows services we have.
which are not visible on the desktop but still running behind.
If there is some possibility, please let me know how to do it.
Allow me to made a superficial (*) explanation:
99% of programs are not visible. Even the ones that seems to be
visible.
A program is "something" defined at the levels of memory, code, ...
(*). The program can have interfaces, that is, channels to receive and
send information.
The C defines some standard interfaces, called stdin, stdout and
stderr. These interfaces are, typically (*), used to introduce data
from the keyboard, and to send text to the screen.
However, when you have a terminal ("command windows", "DOS window",
"X-terminal") and you type data for the program, you are NOT viewing
the program. You are viewing an standard program (the terminal one) and
this program is talking with your program. Thus, even the most easy
program is not "visible".
<OT>
Some other programs, like windows ones, talk with the windows manager,
the X-windows server, ... . In this way, these program can have menus,
buttons, ... . Again, the program itself is not visible: visible (*) is
the X-windows server or the MS windows handler. Finally, tipical
"internet server (*)" programs have TCP/IP interfaces, and talks using
it. These are the ones most part of people calls "invisible".
</OT>
In conclusion, a C program has 3 channels "stdin", "stdout" and
"stderr". If you want the program to run "invisible" you need to 1) run
the program 2) intercept any message from the OS, terminal or manager
that means an interrupt of the program
<OT>
In Unix, or in MS windows with cygwin, this is done like (*):
nohup your_program_name >/dev/null 2>&1 &
</OT>
(*) superficial, inexact description.