Operating System - HP-UX
1827458 Members
5420 Online
109965 Solutions
New Discussion

Re: File Creation Daemon in C

 
SOLVED
Go to solution
Tom Dawson
Regular Advisor

File Creation Daemon in C

Hi,

Does anyone have an example of C code that I can run as a daemon that will monitor a specified directory for the creation of a file?

I'm trying to avoid making "system" calls with "test -f" commands.

Thanks,
Tom
3 REPLIES 3
Jean-Louis Phelix
Honored Contributor
Solution

Re: File Creation Daemon in C

Hi,

Here is an example. Compile it with make, then launch it with a directory as argument. I have commented 2 blocks of lines :

- first one is if you don't want it as a daemon just delete the block, but you will have to use nohup or things like that

- second is to insert you own code when a file has come. I didn't invest too much time in logfile management because I imagine that you won't keep it ... :^)

Regards.
It works for me (© Bill McNAMARA ...)
Tom Dawson
Regular Advisor

Re: File Creation Daemon in C

Jean-Louis,

Thanks!

I'll give it a try tomorrow.

Tom
Tom Dawson
Regular Advisor

Re: File Creation Daemon in C

Jean-Louis,

It worked like a champ, thanks!

I had to make one change. I had to change to .

And I was able to compile it with:

cc -ofilemond filemond.c

Thanks again,
Tom