How do I daemonize a process?

2007-07-23 Thread Garrett Cooper
   As the subject suggests I'm trying to determine how I can daemonize 
a C process, outside of using the rc infrastructure, so that it won't 
exit when the TTY exists. Does anyone know any quick references or examples?

Thanks,
-Garrett
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: How do I daemonize a process?

2007-07-23 Thread Garrett Cooper

Garrett Cooper wrote:
   As the subject suggests I'm trying to determine how I can daemonize 
a C process, outside of using the rc infrastructure, so that it won't 
exit when the TTY exists. Does anyone know any quick references or 
examples?

Thanks,
-Garrett


s/C process/C application process/
s/exists/exits/
s/any quick/of any quick/

   Tonight's not my night for communicating I suppose :(..
-Garrett
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: How do I daemonize a process?

2007-07-23 Thread Simon 'corecode' Schubert

Garrett Cooper wrote:

Garrett Cooper wrote:
   As the subject suggests I'm trying to determine how I can daemonize 
a C process, outside of using the rc infrastructure, so that it won't 
exit when the TTY exists. Does anyone know any quick references or 
examples?

Thanks,
-Garrett


s/C process/C application process/
s/exists/exits/
s/any quick/of any quick/


I suggest daemon(3) if it doesn't have to be portable.

cheers
 simon

--
Serve - BSD +++  RENT this banner advert  +++ASCII Ribbon   /\
Work - Mac  +++  space for low €€€ NOW!1  +++  Campaign \ /
Party Enjoy Relax   |   http://dragonflybsd.org  Against  HTML   \
Dude 2c 2 the max   !   http://golden-apple.biz   Mail + News   / \
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: How do I daemonize a process?

2007-07-23 Thread Garrett Cooper

Jose-Marcio Martins da Cruz wrote:

Simon 'corecode' Schubert wrote:

Garrett Cooper wrote:

Garrett Cooper wrote:
   As the subject suggests I'm trying to determine how I can 
daemonize a C process, outside of using the rc infrastructure, so 
that it won't exit when the TTY exists. Does anyone know any quick 
references or examples?





I suggest daemon(3) if it doesn't have to be portable.


Or something like this, if it has to be portable or if you don't want
to modify C code :

nohup /pathto/c-application 

You'll eventually need to add things like redirect stdout to /dev/null...




   Ok, many thanks for the suggestions all :). I'm more than happy not 
to do the double fork(2) solution =\..

-Garrett
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: How do I daemonize a process?

2007-07-23 Thread Peter Boosten


Simon 'corecode' Schubert wrote:
 Garrett Cooper wrote:
 Garrett Cooper wrote:
As the subject suggests I'm trying to determine how I can
 daemonize a C process, outside of using the rc infrastructure, so
 that it won't exit when the TTY exists. Does anyone know any quick
 references or examples?
 Thanks,
 -Garrett

 s/C process/C application process/
 s/exists/exits/
 s/any quick/of any quick/
 
 I suggest daemon(3) if it doesn't have to be portable.
 

What's wrong with nohup(1)?

Peter
-- 
http://www.boosten.org
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: How do I daemonize a process?

2007-07-23 Thread Jose-Marcio Martins da Cruz

Simon 'corecode' Schubert wrote:

Garrett Cooper wrote:

Garrett Cooper wrote:
   As the subject suggests I'm trying to determine how I can 
daemonize a C process, outside of using the rc infrastructure, so 
that it won't exit when the TTY exists. Does anyone know any quick 
references or examples?





I suggest daemon(3) if it doesn't have to be portable.


Or something like this, if it has to be portable or if you don't want
to modify C code :

nohup /pathto/c-application 

You'll eventually need to add things like redirect stdout to /dev/null...


--
 ---
 Jose Marcio MARTINS DA CRUZ
 Ecole des Mines de Paris  http://j-chkmail.ensmp.fr
 60, bd Saint Michelhttp://www.ensmp.fr/~martins
 75272 - PARIS CEDEX 06  mailto:[EMAIL PROTECTED]
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: How do I daemonize a process?

2007-07-23 Thread Jacques Fourie
On Mon, Jul 23, 2007 at 01:41:00AM -0700, Garrett Cooper wrote:
 Garrett Cooper wrote:
As the subject suggests I'm trying to determine how I can daemonize 
 a C process, outside of using the rc infrastructure, so that it won't 
 exit when the TTY exists. Does anyone know any quick references or 
 examples?
 Thanks,
 -Garrett
 
 s/C process/C application process/
 s/exists/exits/
 s/any quick/of any quick/
 
Tonight's not my night for communicating I suppose :(..
 -Garrett
 ___
 freebsd-hackers@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
 To unsubscribe, send any mail to [EMAIL PROTECTED]

If you can modify the source, have a look at the daemon() function : 
man 3 daemon

jacques
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: How do I daemonize a process?

2007-07-23 Thread Maxime Henrion
Garrett Cooper wrote:
As the subject suggests I'm trying to determine how I can daemonize 
 a C process, outside of using the rc infrastructure, so that it won't 
 exit when the TTY exists. Does anyone know any quick references or examples?
 Thanks,
 -Garrett

The proper way to do this is to use the setsid() function.  If it
is somehow not available on one of your target system, some people
use a hack which consists in calling fork() two times to daemonize
the process; that is supposed to work too.

Cheers,
Maxime
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Dynamic kernel updates using DynAMOS

2007-07-23 Thread Kristis Makris
Hello, please CC me as I'm not registered in these lists.

I'd like to announce DynAMOS, a dynamic kernel updating system that
supports Linux and could be of help in kernel development and high
availability.

This system has been a research project at Arizona State University
for the past 3 years and has finally become publicly available under
the GPL. Feedback would be very much appreciated.

It is an on-the-fly kernel updating system that enables commodity
operating systems to gain adaptive and mutative capabilities without
kernel recompilation or reboot. It employs a new dynamic
instrumentation technique called adaptive function cloning. Execution
flow can be switched adaptively among multiple editions of functions,
possibly concurrently running. This approach becomes the foundation
for dynamic replacement of non-quiescent kernel subsystems when the
timeliness of an update depends on synchronization of multiple kernel
paths.

This system can assist in kernel code prototyping and testing. It can
help fine-tune and benchmark live code (e.g. a scheduling policy) that
would otherwise require a full recompilation and reboot to adjust. It
can also be of help in long-lived systems that need to patch security
holes or benefit from new kernel features without downtime
(e.g. parallel computing clusters). A long-term goal is to automate
dynamically updating a live kernel from one version to the next.

Dynamic updates we've so far been able to carry out with DynAMOS
include:

o Extending the Linux 2.2 kernel process scheduler to support
   unobtrusive, fine-grain cycle stealing offered by the Linger-Longer
   system.

o Introducing adaptive memory paging for efficient gang-scheduling in
   a Linux 2.4 cluster.

o Adaptively updating the Linux pipefs implementation during large
   data transfers.

o Introducing kernel-assisted process checkpointing offered by EPCKPT
   in Linux 2.4.

o Applying security fixes provided by the Openwall project.

o Injecting performance monitoring functionality in kernel functions.

o Updating DynAMOS itself.


The current release is functional on Linux with ports to FreeBSD and
GNU OpenSolaris waiting for bugs to be ironed out. It builds with gcc
3.3 and 2.95, but not 4.x (yet). It comes with examples (e.g. update
get_pid(), update Linux 2.4 scheduler) of dynamic kernel updates for
people to easily try it out and comes prepackaged in .rpm and .deb for
Linux 2.4 (but not 2.2 or 2.6). The source distribution contains the
more complex updates mentioned above (adaptive updating, kernel
thread updates, checkpointing) and if compiled from source will work
for Linux versions 2.2-2.6.


People interested in learning more about the system can read:

o The project webpage: 

   http://freshmeat.net/projects/dynamos/


o The current users manual:


http://files.mkgnu.net/files/dynamos/doc/latest_manual/html-single/manual.html


o A paper published in EuroSys '07 discussing the design and technical
   issues surrounding this work:

  http://files.mkgnu.net/files/dynamos/doc/papers/dynamos_eurosys_07.pdf


o A set of presentation slides that summarize the system:

  http://files.mkgnu.net/files/dynamos/doc/papers/dynamos_eurosys_07.ppt


I hope people will find this work useful and interesting enough for it
to continue being developed.

Thanks,
Kristis



signature.asc
Description: This is a digitally signed message part


Re: How do I daemonize a process?

2007-07-23 Thread Jona Joachim
On Mon, 23 Jul 2007 01:38:40 -0700
Garrett Cooper [EMAIL PROTECTED] wrote:

 As the subject suggests I'm trying to determine how I can
 daemonize a C process, outside of using the rc infrastructure, so
 that it won't exit when the TTY exists. Does anyone know any quick
 references or examples? Thanks,

The daemonize() function in this small program of mine:
http://hcl-club.lu/svn/development/c/console%20c/fetchiterd/fetchiterd.c
is the right portable way to do it according to Advanced Programming
in the UNIX Environment by Stevens and Rago.
(I love that book)

Regards,
Jona
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


A few questions...

2007-07-23 Thread Daniel Molina Wegener

Hello,

   I need information about few things, I hope someone can help
me and thanks in advance.

a) Is there any function or variable that tells me which is the
   root user UID in the system, or root always have 0 and it's
   an elegant option to compare the variables or structure
   members against zero.
b) Can normal users look for system processes or kernel threads?
c) Can root look for system processes or kernel threads?

Regards,
-- 
 .O. | Daniel Molina Wegener   | C/C++ Developer
 ..O | dmw [at] unete [dot] cl | FOSS Coding Adict
 OOO | FreeBSD  Linux User| Standards Rocks!
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: A few questions...

2007-07-23 Thread Darren Pilgrim

Daniel Molina Wegener wrote:

Hello,

   I need information about few things, I hope someone can help
me and thanks in advance.

a) Is there any function or variable that tells me which is the
   root user UID in the system, or root always have 0 and it's
   an elegant option to compare the variables or structure
   members against zero.


Root is always UID 0.  Checking UID == 0 is the common practice for 
determining if the effective UID has root priveleges.



b) Can normal users look for system processes or kernel threads?


Yes, depending on the value of the security.bsd.see_other_uids sysctl. 
If security.bsd.see_other_uids=0, non-root users can only see their own 
processes.



c) Can root look for system processes or kernel threads?


Yes, regardless of the value of security.bsd.see_other_uids.
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


alias netmask bug?

2007-07-23 Thread Evren Yurtesen

Hi,

I remember from earlier versions of FreeBSD that it had a restriction about 
alias IP netmasks (somewhere in 3.x,4.x days)...


as explained here:
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/configtuning-virtual-hosts.html
-
The calculation of alias netmasks is important, but fortunately quite simple. 
For a given interface, there must be one address which correctly represents the 
network's netmask. Any other addresses which fall within this network must have 
a netmask of all 1s (expressed as either 255.255.255.255 or 0x).

-

However I tried on the loopback interface to add a 2nd IP with the same netmask 
as the original IP and it accepts it fine. (on 6.2)


lo0: flags=8049UP,LOOPBACK,RUNNING,MULTICAST mtu 16384
inet 127.0.0.1 netmask 0xff00
inet 127.0.0.2 netmask 0xff00

Is FreeBSD allowing this a bug or ???

If this is not a bug. What happens if an interface which is connecting to the 
machine has 2 IP addresses with same netmask which is not 255.255.255.255? Does 
FreeBSD use each IP randomly?


Thanks,
Evren
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: alias netmask bug?

2007-07-23 Thread Jeremy Chadwick
On Tue, Jul 24, 2007 at 03:34:54AM +0300, Evren Yurtesen wrote:
  I remember from earlier versions of FreeBSD that it had a restriction about 
  alias IP netmasks (somewhere in 3.x,4.x days)...
 
  as explained here:
  
 http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/configtuning-virtual-hosts.html
 
  However I tried on the loopback interface to add a 2nd IP with the same 
  netmask as the original IP and it accepts it fine. (on 6.2)
 
  lo0: flags=8049UP,LOOPBACK,RUNNING,MULTICAST mtu 16384
  inet 127.0.0.1 netmask 0xff00
  inet 127.0.0.2 netmask 0xff00
 
  Is FreeBSD allowing this a bug or ???

It's not a bug.  Why did you disregard the instructions, though?

  If this is not a bug. What happens if an interface which is connecting to 
  the machine has 2 IP addresses with same netmask which is not 
  255.255.255.255? Does FreeBSD use each IP randomly?

Don't know, but my guess is no, it probably does not use each IP
randomly, and I cannot even fathom the network breakage that would
ensue as a result of such.

-- 
| Jeremy Chadwickjdc at parodius.com |
| Parodius Networking   http://www.parodius.com/ |
| UNIX Systems Administrator  Mountain View, CA, USA |
| Making life hard for others since 1977.  PGP: 4BD6C0CB |

___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]