Can 'C' program be run as a background service?

S

Sree

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.
 
V

Vladimir S. Oka

Sree opined:
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.

I'd say it certainly is possible, but you'll have to ask in your
system's group. Standard C does not know about those things.
 
C

Captain Winston

Sree said:
hello friends,

Can i make a C program run as as background service?

Of course, There are so many daemons written in C in Linux.
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.
I'am afraid this question is off topic, you'd better try another group
which is releavent to your platform.
 
V

Vladimir S. Oka

æž—æ°æ° said:
You can get you answer in the book "Windows System Programming".

Who can get, what answer? Quote context!

Since you replied to my post, you could have at least bothered to read
the link in my sig. Go do it now...
 
G

Guest

Dear Vladimir S. Oka,
I mean Sree can get the answer to the problem that weather 'C'
program can be run as a background service in the book 'Windows System
programming'
 
T

tmp123

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.
 
F

Flash Gordon

tmp123 said:
Allow me to made a superficial (*) explanation:

Very supercicial and not even necessarily close to being accurate.
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".

No, on some hosted systems you don't have a "terminal program" between
your executable and the display/keyboard.
<OT>
Some other programs, like windows ones, talk with the windows manager,
the X-windows server, ... . In this way, these program can have menus,

Completely messed up, Windows generally does not use an X-windows server
it has it's own system, and many *nix systems don't either.
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".

They are only a small percentage of the services running on my Windows
machine, and on my *nix boxes many internet services do not talk TCP/IP
but use something else to do that.
</OT>

In conclusion, a C program has 3 channels "stdin", "stdout" and
"stderr".
Correct.

> 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

It's not always as simple as that, and sometimes not as complex as that.
<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.

That is terrible advice for either Windows or *nix. If you want to write
a Windows service you should write the code to register it with the
service manager so people can manage it in the expected way. If writing
a service for *nix you want to do something so that the system
administrator can see anything the service wants to report, throwing the
information away is not a good idea.

If you want to discus services further, go to a group dedicated to the
implementation of interest. There people will properly vet the answers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top