Fedora Linux Support Community & Resources Center
  #1  
Old 29th July 2006, 02:41 PM
Knudson's Avatar
Knudson Offline
Registered User
 
Join Date: Mar 2005
Location: Italy
Age: 28
Posts: 401
How to program a daemon?

Hi all

i wrote a simple C program for automated video recording for security reasons, it works good and it runs from shell, so i don't need any KDE or Gnome or whatever. But, here's my problem: that computer is a blind pc (no monitor and in an unreachable place) so i need to control it remotely : the problem is that if i use SSH to launch the program when i close the ssh session, it kills also the program. Now i've workarounded it using vnc :| but it's really a waste of resources. So , my question is: how do i make that program a daemon? I need something like amueld -f

Program is in C/C++ and is running under FC5, any advice or link is welcome, thanks
__________________
knu - ICQ# 51135890
knu.altervista.org
Help us to give linux a better software support!
Shooby dooby doo shooby dooby doo durul
Reply With Quote
  #2  
Old 29th July 2006, 02:53 PM
brunson Offline
Registered User
 
Join Date: Jun 2005
Location: Westminster, Colorado
Posts: 2,304
You call fork(), which clones your process space into two processes, then exit from the parent process. Read the man page for fork(2) for specifics. You can also try using "nohup" from the shell you're starting in.
__________________
Registered Linux User #4837
411th in line to get sued by Micro$oft
Quote:
Basically, to learn Unix you learn to understand and apply a small set of key ideas and achieve expertise by expanding both the set of ideas and your ability to apply them - Paul Murphy

Last edited by brunson; 29th July 2006 at 02:55 PM.
Reply With Quote
  #3  
Old 29th July 2006, 03:36 PM
Knudson's Avatar
Knudson Offline
Registered User
 
Join Date: Mar 2005
Location: Italy
Age: 28
Posts: 401
and will it work with fork? If the parent process dies then also the child process will..or not?
__________________
knu - ICQ# 51135890
knu.altervista.org
Help us to give linux a better software support!
Shooby dooby doo shooby dooby doo durul
Reply With Quote
  #4  
Old 29th July 2006, 04:09 PM
ms1234's Avatar
ms1234 Offline
Registered User
 
Join Date: Apr 2005
Posts: 323
Why not run it under screen?
Reply With Quote
  #5  
Old 29th July 2006, 07:08 PM
markkuk Offline
Registered User
 
Join Date: Apr 2005
Location: Finland
Posts: 5,076
See the daemon() function, "man 3 daemon".
Reply With Quote
  #6  
Old 29th July 2006, 09:03 PM
brunson Offline
Registered User
 
Join Date: Jun 2005
Location: Westminster, Colorado
Posts: 2,304
Quote:
and will it work with fork? If the parent process dies then also the child process will..or not?
It's five lines of code, try it and find out.
__________________
Registered Linux User #4837
411th in line to get sued by Micro$oft
Quote:
Basically, to learn Unix you learn to understand and apply a small set of key ideas and achieve expertise by expanding both the set of ideas and your ability to apply them - Paul Murphy
Reply With Quote
  #7  
Old 30th July 2006, 12:15 AM
Knudson's Avatar
Knudson Offline
Registered User
 
Join Date: Mar 2005
Location: Italy
Age: 28
Posts: 401
Markkuk thanks a lot, that's what i needed !
__________________
knu - ICQ# 51135890
knu.altervista.org
Help us to give linux a better software support!
Shooby dooby doo shooby dooby doo durul
Reply With Quote
Reply

Tags
daemon, program

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ daemon and talking to daemon soxs060389 Programming & Packaging 8 27th May 2009 04:55 PM
How to run java program as daemon pssvarma8881 Programming & Packaging 1 21st June 2007 03:24 PM
Avahi daemon and HAL daemon lsatenstein Fedora Core 5 - Dev 18 14th February 2006 01:37 AM


Current GMT-time: 05:08 (Thursday, 23-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat