Unix Programming - Writing a Unix Daemon

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > May 2006 > Writing a Unix Daemon





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Writing a Unix Daemon
NS

2006-05-19, 1:25 am

Hi,
I am trying to write a UNIX daemon and I happened to come across a
sample at this link: http://www.enderunix.org/docs/eng/daemon.php

I downloaded the examped.c program and when I trying to compile it I
keep getting the following error message (since we don't have the C
compiler installed I had to use gcc compiler). The UNIX OS that I am
using is Sun 5.9

Start of error message
-----------------------------------------------------------------------------------------------------------------------------------------------------
In file included from
/tool/depot/cygnus-95q4/lib/gcc-lib/sparc-sun-solaris2.5/2.7-95q4/include/time.h:90,
from /usr/include/sys/time.h:418,
from /usr/include/sys/select.h:20,
from
/tool/depot/cygnus-95q4/lib/gcc-lib/sparc-sun-solaris2.5/2.7-95q4/include/sys/types.h:278,
from /usr/include/fcntl.h:23,
from examped.c:14:
/usr/include/sys/siginfo.h:74: syntax error before `pthread_attr_t'
In file included from
/tool/depot/cygnus-95q4/lib/gcc-lib/sparc-sun-solaris2.5/2.7-95q4/include/time.h:90,
from /usr/include/sys/time.h:418,
from /usr/include/sys/select.h:20,
from
/tool/depot/cygnus-95q4/lib/gcc-lib/sparc-sun-solaris2.5/2.7-95q4/include/sys/types.h:278,
from /usr/include/fcntl.h:23,
from examped.c:14:
/usr/include/sys/siginfo.h:284: syntax error before `int32_t'
/usr/include/sys/siginfo.h:415: syntax error before `int32_t'
-----------------------------------------------------------------------------------------------------------------------------------------------------
End of error message


I am essentially trying to build a daemon that can sense changes made
to a particular file and then do some actions based on the type of
change made to that file.

Any help in this matter is greatly appreciated.


Thanks,
NS

Gordon Burditt

2006-05-19, 1:25 am

> I am trying to write a UNIX daemon and I happened to come across a
>sample at this link: http://www.enderunix.org/docs/eng/daemon.php
>
> I downloaded the examped.c program and when I trying to compile it I
>keep getting the following error message (since we don't have the C
>compiler installed I had to use gcc compiler). The UNIX OS that I am
>using is Sun 5.9


If you get syntax errors in system include files, it probably means
that you forgot to include a prerequesite include file FIRST that
defines some typedefs. <sys/types.h> is often a prerequesite for <sys/*.h>.

What include file defines int32_t (<inttypes.h>?) and pthread_attr_t?

Gordon L. Burditt

>Start of error message
>-----------------------------------------------------------------------------------------------------------------------------------------------------
>In file included from
>/tool/depot/cygnus-95q4/lib/gcc-lib/sparc-sun-solaris2.5/2.7-95q4/include/time.h:90,
>from /usr/include/sys/time.h:418,
>from /usr/include/sys/select.h:20,
>from
>/tool/depot/cygnus-95q4/lib/gcc-lib/sparc-sun-solaris2.5/2.7-95q4/include/sys/types.h:278,
>from /usr/include/fcntl.h:23,
>from examped.c:14:
>/usr/include/sys/siginfo.h:74: syntax error before `pthread_attr_t'
>In file included from
>/tool/depot/cygnus-95q4/lib/gcc-lib/sparc-sun-solaris2.5/2.7-95q4/include/time.h:90,
>from /usr/include/sys/time.h:418,
>from /usr/include/sys/select.h:20,
>from
>/tool/depot/cygnus-95q4/lib/gcc-lib/sparc-sun-solaris2.5/2.7-95q4/include/sys/types.h:278,
>from /usr/include/fcntl.h:23,
>from examped.c:14:
>/usr/include/sys/siginfo.h:284: syntax error before `int32_t'
>/usr/include/sys/siginfo.h:415: syntax error before `int32_t'
>-----------------------------------------------------------------------------------------------------------------------------------------------------
>End of error message

Spoon

2006-05-19, 1:17 pm

Gordon Burditt wrote:
> What include file defines int32_t (<inttypes.h>?)


http://www.opengroup.org/onlinepubs...s/stdint.h.html

> and pthread_attr_t?


http://www.opengroup.org/onlinepubs...ys/types.h.html
NS

2006-05-19, 1:17 pm

Gordon and Spoon,
Thanks for your response. I included both <stdint.h> and <sys/types.h>
and when try to compile it I am getting following error.

Start of error message
--------------------------------------------------------------------------------
examped.c:17: stdint.h: No such file or directory
--------------------------------------------------------------------------------
End of error message

Does this mean that I don't have the stdint.h file or am I not
including any prerequisites?

Thanks and really appreciate your help.

Thanks,
NS

Spoon wrote:
> Gordon Burditt wrote:
>
> http://www.opengroup.org/onlinepubs...s/stdint.h.html
>
>
> http://www.opengroup.org/onlinepubs...ys/types.h.html


NS

2006-05-19, 1:17 pm

Hi,
I was able get the examped.c program (which is available at the above
mentioned link) compiled after I followed your suggestions. I had to
include the following headers to compile the sample.

#include </usr/include/sys/types.h>
#include </usr/include/sys/int_types.h>
#include <stdio.h>
#include <fcntl.h>
#include <signal.h>
#include <unistd.h>

Now I am trying to see if I create my own daemon program based on this
example.

As I mentioned earlier, what I am trying to do is to create a daemon
that will watch a specific file and upon any edits to that file, the
daemon will spawn a child process to execute certain tasks based on the
type of modification done the file and then report back to the daemon
server.

Since I am very new to writing daemons, if you could give me some
pointers or examples on how to achieve what I described, it would have
great help.

Thanks again,
NS

NS wrote:[vbcol=seagreen]
> Gordon and Spoon,
> Thanks for your response. I included both <stdint.h> and <sys/types.h>
> and when try to compile it I am getting following error.
>
> Start of error message
> --------------------------------------------------------------------------------
> examped.c:17: stdint.h: No such file or directory
> --------------------------------------------------------------------------------
> End of error message
>
> Does this mean that I don't have the stdint.h file or am I not
> including any prerequisites?
>
> Thanks and really appreciate your help.
>
> Thanks,
> NS
>
> Spoon wrote:

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com