LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-01-2009, 01:30 AM   #1
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
How to add a new daemon process in MINIX operating system ?


I want to write an operating system of my own ! I've started studying Minix. For getting started I wanted to know is there a way to write and add a background process [printing 'hello'] in the Minix operating system ?

Kindly help !
 
Old 10-01-2009, 01:40 AM   #2
Fallen_Demon
LQ Newbie
 
Registered: Sep 2009
Location: Australia
Distribution: Ubuntu
Posts: 13

Rep: Reputation: 2
If it's anything like Linux (I haven't used MINIX, so I don't know exactly sorry), you write something like this:

Code:
#include<unistd.h>
#include<stdio.h>

int main(int argc, char* argv[]){
  if(fork()){
    printf("I'm the parent!\n");
    return 0;
  }  
  else{
    printf("I'm the child");
    /*daemon loop here*/
  }
  return 0;
}
What this does is spawns a new child, and then the parent exits. The now orphaned child process is 'adopted' by init and continues to run. I think there's also a function actually called daemon(), but I've never used it so I can't be sure.

EDIT: Ahh, there is indeed a non-standard function (from BSD4.4 it looks like) called daemon(). It takes two integers, the first is whether or not to change the working directory to / and the second whether or not to pipe all output to /dev/null. It isn't part of POSIX, though, so for portability don't use it

Last edited by Fallen_Demon; 10-01-2009 at 01:56 AM.
 
Old 10-01-2009, 02:02 AM   #3
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731

Original Poster
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Thanks for the reply,

I already know the fork() system call you talked about, but the point is that if you do a 'ps -e' on a linux shell, you'll see a number of processes already running there. All i understand is that they were written inside the linux operating system thats why they automatically start running on the system startup ! I wanted to write a process which gets automatically started up when the system starts.
 
Old 10-01-2009, 11:41 PM   #4
Fallen_Demon
LQ Newbie
 
Registered: Sep 2009
Location: Australia
Distribution: Ubuntu
Posts: 13

Rep: Reputation: 2
It'd just be a matter of editing the /etc/rc.d scripts. I'm not overly knowledgeable on the Linux boot process, but there is ample documentation out there to help
 
Old 10-02-2009, 11:20 PM   #5
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731

Original Poster
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
actually i got confused about linux kernel processes and linux kernel modules. Do you think both of them are same !
 
Old 10-04-2009, 01:05 AM   #6
Fallen_Demon
LQ Newbie
 
Registered: Sep 2009
Location: Australia
Distribution: Ubuntu
Posts: 13

Rep: Reputation: 2
They're definitely not the same Kernel modules run in kernel space, while daemons generally run in userspace. I haven't written any modules myself (it's in my todo list), but you might want to have a look at the Kernel Newbies site for some tips
 
Old 10-04-2009, 11:53 PM   #7
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731

Original Poster
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
thanks for the info ! I need to study more the on deamons and kernel modules !
 
Old 10-05-2009, 11:18 PM   #8
Fallen_Demon
LQ Newbie
 
Registered: Sep 2009
Location: Australia
Distribution: Ubuntu
Posts: 13

Rep: Reputation: 2
Not a problem
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i add more drives in already installed linux operating system/fedora11 Budhayash Linux - Hardware 2 08-21-2009 03:25 AM
how can i add more drives in already installed linux operating system/fedora11 Budhayash Linux - Newbie 1 08-20-2009 04:04 AM
how to add a process start during the system boot rajesh84210 Linux - General 2 07-27-2009 02:47 AM
'Operating system not found' Any operating system installed wont work. TechniSlave Linux - Newbie 55 02-09-2009 11:02 AM
What should I do to add more harddisk to my linux operating system? marhen Linux - Hardware 1 06-15-2008 07:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:20 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
Open Source Consulting | Domain Registration