* debugging a libnetfilter_queue program and stdout
@ 2016-02-17 19:12 Michael D. Berger
2016-02-20 20:42 ` Adel Belhouane
0 siblings, 1 reply; 2+ messages in thread
From: Michael D. Berger @ 2016-02-17 19:12 UTC (permalink / raw)
To: netfilter
I wrote a program using libnetfilter_queue. Call it "tst".
It normally runs as a service, but when I am debugging it, I
put some printf statements in it and run it in the foreground
by typing:
tst
and the printf results appear on the screen as expected. However,
if I expect a long output, I would rather type:
tst > log
hoping to see the results in the file "log". However, "log" is
always empty, even though I have other indications that "tst" is
running.
Why is this? Is there anything I could do to get the printf
results to appear in "log"?
Thanks,
Mike.
--
Michael D. Berger
m.d.berger@ieee.org
http://www.rosemike.net/
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: debugging a libnetfilter_queue program and stdout
2016-02-17 19:12 debugging a libnetfilter_queue program and stdout Michael D. Berger
@ 2016-02-20 20:42 ` Adel Belhouane
0 siblings, 0 replies; 2+ messages in thread
From: Adel Belhouane @ 2016-02-20 20:42 UTC (permalink / raw)
To: Michael D. Berger; +Cc: netfilter
Le 17/02/2016 20:12, Michael D. Berger a écrit :
> I wrote a program using libnetfilter_queue. Call it "tst".
> It normally runs as a service, but when I am debugging it, I
> put some printf statements in it and run it in the foreground
> by typing:
>
> tst
>
> and the printf results appear on the screen as expected. However,
> if I expect a long output, I would rather type:
>
> tst > log
>
> hoping to see the results in the file "log". However, "log" is
> always empty, even though I have other indications that "tst" is
> running.
>
> Why is this? Is there anything I could do to get the printf
> results to appear in "log"?
>
Not related to netfilter but only C, anyway... when the output is a
file, printf (to stdout) is block buffered instead of line buffered for
a terminal. You'd need more output to fill the first block. Check the
man pages of fflush(3) and setvbuf(3) to know how to have it as you expect.
According to these man pages if you were using stderr (with fprintf() )
it would be already unbuffered and tst 2>log would "work".
> Thanks,
> Mike.
>
> --
> Michael D. Berger
> m.d.berger@ieee.org
> http://www.rosemike.net/
>
regards,
Adel Belhouane.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-02-20 20:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-17 19:12 debugging a libnetfilter_queue program and stdout Michael D. Berger
2016-02-20 20:42 ` Adel Belhouane
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.