All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: oliver.schlenker@domain.hid
Cc: jan.kiszka@domain.hid, xenomai@xenomai.org
Subject: Re: [Xenomai-help] Re : rt_printf with daemonized task
Date: Thu, 08 Oct 2009 15:33:38 +0200	[thread overview]
Message-ID: <4ACDEA32.70502@domain.hid> (raw)
In-Reply-To: <0000ACDD.4ACE037F@192.168.2.103>

oliver.schlenker@domain.hid wrote:
> Did change my test code in the meantime to :
> 
> 
> #include <stdlib.h>
> #include <stdio.h>
> 
> #include <native/task.h>
> #include <native/timer.h>
> #include <rtdk.h>
> 
> 
> int main( int arc, char *argv[] )
> {
> int i;
> 
> daemon(0,1);
> 
> __rt_print_init();
> 
> rt_print_auto_init(1);
> 
> rt_printf("--------------- TEST RT-PRINTF ------------\n");
> 
> sleep(10);
> 
> return(0);
> }
> 
> 
> and everything works fine at first glance.
> 
> There is at least an output to syslog of the rt_printf message. I have
> no idea if this creates an internal memory leak. For my application
> it might be not a real problem, because the fork is done only once.
> For application with several fork calls or a recursional fork calls it might be
> not ok.

Calling fork inside an application which has several running threads is
already insane. Think about it: if the running threads had a mutex
locked, the mutex will still appear as locked in the child process and
can not be unlocked. The threads will not exist in the child process,
but their stacks and allocated tsd will still exists. posix proposes
pthread_atfork to solve these issues, but not forking in a process with
threads is more sane (the exception being to call fork+exec or
vfork+exec, since in that case the virtual memory space will be wiped
out by exec, so we do not care about the leaks anyway).

-- 
                                          Gilles



  parent reply	other threads:[~2009-10-08 13:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-08 13:21 [Xenomai-help] Re : rt_printf with daemonized task oliver.schlenker
2009-10-08 13:27 ` Jan Kiszka
2009-10-08 13:33 ` Gilles Chanteperdrix [this message]
  -- strict thread matches above, loose matches on Subject: below --
2009-10-08  7:22 oliver.schlenker
2009-10-08  8:26 ` Gilles Chanteperdrix
2009-10-08  9:26   ` Jan Kiszka
2009-10-08  9:33     ` Gilles Chanteperdrix
2009-10-08 10:16       ` Jan Kiszka
2009-10-08 12:19         ` Gilles Chanteperdrix
2009-10-08 13:08           ` Jan Kiszka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4ACDEA32.70502@domain.hid \
    --to=gilles.chanteperdrix@xenomai.org \
    --cc=jan.kiszka@domain.hid \
    --cc=oliver.schlenker@domain.hid \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.