* [Xenomai-help] Re-8: rt_printf with daemonized task
@ 2009-10-07 15:20 oliver.schlenker
2009-10-07 15:24 ` Gilles Chanteperdrix
2009-10-07 15:38 ` Jan Kiszka
0 siblings, 2 replies; 3+ messages in thread
From: oliver.schlenker @ 2009-10-07 15:20 UTC (permalink / raw)
To: gilles.chanteperdrix; +Cc: xenomai
As you expected, changing the syslog call from
syslog( LOG_ERR | LOG_LOCAL4, head->text );
to
syslog( LOG_ERR | LOG_LOCAL4, "%s", head->text );
did not change anything.
To track down the problem further, I have made a small test application :
#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;
rt_print_auto_init(1);
rt_printf("--------------- TEST RT-PRINTF 1 ------------\n");
sleep(1);
daemon(0,0);
rt_print_auto_init(1);
rt_printf("--------------- TEST RT-PRINTF 2 ------------\n");
sleep(10);
return(0);
}
This application gives the following results :
- If the daemon() function is not called, all rt_printf() do work well
and output is shown in syslog
- If daemon() function is called, and first call to sleep(1) is omitted,
there is no output in the syslog whatsoever.
- If daemon() function is called, and first call to sleep(1) is executed,
there is output of the first rt_printf in the syslog but not of the second
one.
I do not have any idea why daemonizing of the process is not giving
any output to the syslog.
Oliver
-------- Original Message --------
Subject: Re: Re-6: [Xenomai-help] rt_printf with daemonized task (07-Okt-2009 15:49)
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: oliver.schlenker@smmotioncontrol.de
> oliver.schlenker@smmotioncontrol.de wrote:
> >
> >
> > in the glibc documentation it's specified as a void function :
> >
> > 18.2.2 syslog, vsyslog
> >
> > The symbols referred to in this section are declared in the file syslog.h.
> > — Function: void syslog (int facility_priority, char *format, ...)
>
> So, the first argument is a format string? You should pass "%s" followed
> by head->text then, not head->text directly. If head->text contains the
> % characters, you will get errors. I do not think fixing this will fix
> your issues though.
>
> I have no idea why it fails. Did you try to put a printf as well as the
> syslog call to check whether syslog is really called? Are you 100% sure
> that you do not close file descriptors when daemonizing your process?
>
>
> --
> Gilles
>
To: gilles.chanteperdrix@xenomai.org
Cc: xenomai-help@gna.org
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Xenomai-help] Re-8: rt_printf with daemonized task
2009-10-07 15:20 [Xenomai-help] Re-8: rt_printf with daemonized task oliver.schlenker
@ 2009-10-07 15:24 ` Gilles Chanteperdrix
2009-10-07 15:38 ` Jan Kiszka
1 sibling, 0 replies; 3+ messages in thread
From: Gilles Chanteperdrix @ 2009-10-07 15:24 UTC (permalink / raw)
To: oliver.schlenker; +Cc: xenomai
oliver.schlenker@domain.hid wrote:
>
>
> As you expected, changing the syslog call from
> syslog( LOG_ERR | LOG_LOCAL4, head->text );
> to
> syslog( LOG_ERR | LOG_LOCAL4, "%s", head->text );
>
> did not change anything.
>
> To track down the problem further, I have made a small test application :
>
> #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;
>
> rt_print_auto_init(1);
>
> rt_printf("--------------- TEST RT-PRINTF 1 ------------\n");
>
> sleep(1);
>
> daemon(0,0);
>
> rt_print_auto_init(1);
>
> rt_printf("--------------- TEST RT-PRINTF 2 ------------\n");
>
> sleep(10);
>
> return(0);
> }
>
>
>
> This application gives the following results :
> - If the daemon() function is not called, all rt_printf() do work well
> and output is shown in syslog
> - If daemon() function is called, and first call to sleep(1) is omitted,
> there is no output in the syslog whatsoever.
> - If daemon() function is called, and first call to sleep(1) is executed,
> there is output of the first rt_printf in the syslog but not of the second
> one.
>
> I do not have any idea why daemonizing of the process is not giving
> any output to the syslog.
Could you try daemon(0, 1)?
Could you also try to send normal replies to our replies, not mails
which do not appear as replies and start new threads?
Could you also remove the annoying feature that ask me to confirm that I
want you to be notified that I read your mail?
--
Gilles
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Xenomai-help] Re-8: rt_printf with daemonized task
2009-10-07 15:20 [Xenomai-help] Re-8: rt_printf with daemonized task oliver.schlenker
2009-10-07 15:24 ` Gilles Chanteperdrix
@ 2009-10-07 15:38 ` Jan Kiszka
1 sibling, 0 replies; 3+ messages in thread
From: Jan Kiszka @ 2009-10-07 15:38 UTC (permalink / raw)
To: oliver.schlenker; +Cc: xenomai
oliver.schlenker@domain.hid wrote:
>
>
> As you expected, changing the syslog call from
> syslog( LOG_ERR | LOG_LOCAL4, head->text );
> to
> syslog( LOG_ERR | LOG_LOCAL4, "%s", head->text );
>
> did not change anything.
>
> To track down the problem further, I have made a small test application :
>
> #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;
>
> rt_print_auto_init(1);
>
> rt_printf("--------------- TEST RT-PRINTF 1 ------------\n");
>
> sleep(1);
>
> daemon(0,0);
>
> rt_print_auto_init(1);
>
> rt_printf("--------------- TEST RT-PRINTF 2 ------------\n");
>
> sleep(10);
>
> return(0);
> }
>
>
>
> This application gives the following results :
> - If the daemon() function is not called, all rt_printf() do work well
> and output is shown in syslog
> - If daemon() function is called, and first call to sleep(1) is omitted,
> there is no output in the syslog whatsoever.
> - If daemon() function is called, and first call to sleep(1) is executed,
> there is output of the first rt_printf in the syslog but not of the second
> one.
>
> I do not have any idea why daemonizing of the process is not giving
> any output to the syslog.
As you are already looking at rt_printf.c: __rt_print_init spawns a
pthread that polls the internal queues and issues the output to stdout
or whatever. On fork (or daemonize), this thread is not replicated. So
the child process simply has no printing thread.
I think this should be fixable with a pthread_atfork hook, patches
always welcome.
Jan
--
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-10-07 15:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-07 15:20 [Xenomai-help] Re-8: rt_printf with daemonized task oliver.schlenker
2009-10-07 15:24 ` Gilles Chanteperdrix
2009-10-07 15:38 ` Jan Kiszka
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.