LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Blogs > bogoda
User Name
Password

Notices

Rate this Entry

Run Daemon in linux

Posted 01-13-2006 at 07:20 AM by bogoda

HI ,

I am new to Red Hat 9.

I want to know how can i create a Deamon program to run in linux when system boot up.

I run the following program.

But no out put.

I want set it as Daemon.


#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <syslog.h>
#include <string.h>

int main(void) {

/* Our process ID and Session ID */
pid_t pid, sid;

/* Fork off the parent process */
pid = fork();
if (pid < 0) {

exit(EXIT_FAILURE);
}

/* Close out the standard file descriptors */
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);

/* Daemon-specific initialization goes here */

/* The Big Loop */
while (1) {

printf("Inside Enter j:");
/* Do some task here ... */
sleep(100); /* wait 30 seconds */
}
//exit(EXIT_SUCCESS);
}





Any one kow the solution plse.


Thank you.
Posted in Uncategorized
Views 1699 Comments 2
« Prev     Main     Next »
Total Comments 2

Comments

  1. Old Comment
    If any one know this.
    Posted 12-31-1969 at 07:00 PM by bogoda bogoda is offline
  2. Old Comment
    This(as well as the post above this) should be posted in the forums.
    Posted 12-31-1969 at 07:00 PM by bogoda bogoda is offline
 

  



All times are GMT -5. The time now is 08:36 PM.

Main Menu
Advertisement

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