From: Adel Belhouane <bugs.a.b@free.fr>
To: "Michael D. Berger" <m.d.berger@ieee.org>
Cc: netfilter@vger.kernel.org
Subject: Re: debugging a libnetfilter_queue program and stdout
Date: Sat, 20 Feb 2016 21:42:17 +0100 [thread overview]
Message-ID: <56C8CFA9.3030500@free.fr> (raw)
In-Reply-To: <0O2P00CI3HCLQG40@vms173025.mailsrvcs.net>
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.
prev parent reply other threads:[~2016-02-20 20:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-17 19:12 debugging a libnetfilter_queue program and stdout Michael D. Berger
2016-02-20 20:42 ` Adel Belhouane [this message]
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=56C8CFA9.3030500@free.fr \
--to=bugs.a.b@free.fr \
--cc=m.d.berger@ieee.org \
--cc=netfilter@vger.kernel.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.