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

Discussion in 'C Programming' started by Sree, Mar 30, 2006.

  1. Sree

    Sree Guest

    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.
    Sree, Mar 30, 2006
    #1
    1. Advertising

  2. 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>
    Vladimir S. Oka, Mar 30, 2006
    #2
    1. Advertising

  3. You can get you answer in the book "Windows System Programming".
    =?utf-8?B?5p6X5p2w5p2w?=, Mar 30, 2006
    #3
  4. 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.
    Captain Winston, Mar 30, 2006
    #4
  5. æž—æ°æ° 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>
    Vladimir S. Oka, Mar 30, 2006
    #5
  6. 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'
    =?utf-8?B?5p6X5p2w5p2w?=, Mar 30, 2006
    #6
  7. 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...*_*
    =?utf-8?B?5p6X5p2w5p2w?=, Mar 30, 2006
    #7
  8. Sree

    tmp123 Guest

    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.
    tmp123, Mar 30, 2006
    #8
  9. Sree

    Flash Gordon Guest

    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
    Flash Gordon, Mar 30, 2006
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. duncan
    Replies:
    2
    Views:
    6,059
  2. Shawn
    Replies:
    2
    Views:
    1,439
    Shawn
    Dec 6, 2006
  3. bilik
    Replies:
    0
    Views:
    224
    bilik
    Apr 16, 2011
  4. Jason Barnett

    Web Service as a background service

    Jason Barnett, Oct 9, 2008, in forum: ASP .Net Web Services
    Replies:
    2
    Views:
    136
    John Saunders
    Oct 10, 2008
  5. Yesterday Paid
    Replies:
    1
    Views:
    248
    Dave Angel
    Jun 21, 2012
Loading...

Share This Page