Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Can 'C' program be run as a background service?

Reply
Thread Tools

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

 
 
Sree
Guest
Posts: n/a
 
      03-30-2006
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.

 
Reply With Quote
 
 
 
 
Vladimir S. Oka
Guest
Posts: n/a
 
      03-30-2006
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.

--
You are a very redundant person, that's what kind of person you are.

<http://clc-wiki.net/wiki/Introduction_to_comp.lang.c>

 
Reply With Quote
 
 
 
 
=?utf-8?B?5p6X5p2w5p2w?=
Guest
Posts: n/a
 
      03-30-2006
You can get you answer in the book "Windows System Programming".

 
Reply With Quote
 
Captain Winston
Guest
Posts: n/a
 
      03-30-2006

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

 
Reply With Quote
 
Vladimir S. Oka
Guest
Posts: n/a
 
      03-30-2006

林杰杰 wrote:
> 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...

--
<http://clc-wiki.net/wiki/Introduction_to_comp.lang.c>

 
Reply With Quote
 
=?utf-8?B?5p6X5p2w5p2w?=
Guest
Posts: n/a
 
      03-30-2006
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'

 
Reply With Quote
 
=?utf-8?B?5p6X5p2w5p2w?=
Guest
Posts: n/a
 
      03-30-2006
Vladimir S. Oka wrote:
>Since you replied to my post, you could have at least bothered to read

the link in my sig. Go do it now...

I'm sorry, I forgot again...*_*

 
Reply With Quote
 
tmp123
Guest
Posts: n/a
 
      03-30-2006
Sree wrote:
> 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.

 
Reply With Quote
 
Flash Gordon
Guest
Posts: n/a
 
      03-30-2006
tmp123 wrote:
> Sree wrote:
>> 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:


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.
--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro:
http://clc-wiki.net/wiki/Intro_to_clc
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can parellelized program run slower than single process program? Yesterday Paid Python 1 06-21-2012 05:58 AM
how can I run sniff() in background? bilik Python 0 04-16-2011 02:26 PM
Program will not run, used to run, have reinstalled numerous times,no luck Boppy NZ Computing 15 01-24-2011 10:30 AM
Can Java program evoke and run a FORTRAN program directly? Shawn Java 2 12-06-2006 07:08 PM
can run javascript can't run vbscript - WHY duncan ASP .Net 2 10-27-2004 09:31 AM



Advertisments