473,405 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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

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.

Mar 30 '06 #1
8 9261
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>

Mar 30 '06 #2
You can get you answer in the book "Windows System Programming".

Mar 30 '06 #3

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.

Mar 30 '06 #4

林杰杰 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>

Mar 30 '06 #5
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'

Mar 30 '06 #6
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...*_*

Mar 30 '06 #7
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.

Mar 30 '06 #8
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
Mar 30 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: pokmon | last post by:
Ok, I want to implmement a "backgound process", but the catch is this: I want to control it via a Web Service, that is to say, the Web Service will be its API. What type of application should...
1
by: Ed | last post by:
Is there a way to run an application in the background other than through a service. As I understand it when creating a service it is best practice not have any kind of user interface. My...
3
by: Joe | last post by:
Dear Friends, How to run the C# Console application as services? I have a console application.I want run this application as background services.User don't want see the command propmt. If anyone...
4
by: Mrinal Kamboj | last post by:
Hi , Doubt may be bit trivial , but i wanted to know , what are the exact benefits derived while we run a background process as an NT service in windows , we can as well achieve the...
5
by: James | last post by:
Hi, I working on an ASP .NET project, in this project I need to link my project with another program to retrieve data, how can I do that? I have access to source code of the other program where...
17
by: UJ | last post by:
Is there any way for a windows service to start a windows program ? I have a service that will need to restart a windows app if it needs to. TIA - Jeff.
6
by: AzenAlex | last post by:
I have a fairly large application written in C# that i would now like to run as a service. Is there a simple way to do this?
3
by: PRR | last post by:
I have a console program.. which i need to convert to a windows service... My basic requirement is that the program needs to run in background and consume as less memory n CPU time as possible..I am...
3
by: jim3371 | last post by:
Using wxPython, I'm looking to build a GUI app for a daemon-based app, on Win32 platform, how would I go about executing the daemon app so it stays in the background when the Py app is running?...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.