Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 02-07-2007, 12:49 PM   #1
LQ Newbie
Registered: Jul 2005
Distribution: Gentoo
Posts: 3

Rep: Reputation: 0
Question Programming Linux Daemon


I am trying to code a program that runs in the background and monitors access on my local files. If an access is requested to a file that doesn't exist, it should download it from the fileserver. I assume the best approach for doing so is by coding a daemon. Are there any tutorials on the internet for doing so? From what I have read, a daemon is a normal process, but has redirected stdin, stdout and stderr file descriptors and has init as it's parent process. But I'm pretty sure there must be more to coding a daemon. Also I'm not sure if it's possible to monitor other processes file requests. Anyone know if possible and how to do it? If it's not possible, the alternative is to force the other processes to request data from the daemon (ie. rewrite the other apps, breaking compatibility with 3rd party apps). Thanks,

Old 02-07-2007, 02:22 PM   #2
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 30
I can't give you all the answers you need, but I can give you two of them.

=== answer one ===

If you decide to use a daemon, there are several non-obvious things you should do. They are listed here:

(Scroll down to the section "Types of daemons".)

Sample code for creating a daemon can be found here:

A discussion of mistakes to avoid when coding a daemon can be found here:

I'm not sure whether I agree with everything they say, but it's still worth reading.

=== answer two

It's not easy to monitor other processes' open()ing of files. The best you can do is modify the code when you have the source available. The next best thing is to hope that software for which you do not have the packages uses shared libraries. Then you need to modify the open() (or maybe __open()) calls to hook up to your daemon if the file does not exist.

This is only a start. You have much more to learn; I'm glad I don't have to!

Hope this helps.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
damon programming....Why cant my daemon create files? vimes Programming 4 03-16-2006 05:38 AM
Daemon programming.... Help rajsun Programming 7 02-01-2006 11:23 PM
Daemon programming..... rajsun Programming 11 07-01-2005 06:12 AM
Daemon Server Programming.... HELP rajsun Programming 2 04-05-2005 03:28 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:12 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration