stdout problem (flush?)

37 views
Skip to first unread message

opichals

unread,
Feb 5, 2010, 5:04:53 AM2/5/10
to nodejs
Hi!

Made nodejs a part of my build system where I use it to go through
the .js files to extract some information. I print a bunch of
information out via sys.puts() but it seems that it sometimes get an
empty file. It looks like nodejs tries hard to have the stdout
nonblocking, but doesn't wait for the stdout to be written before
exit. I had a look at where i could just add
fflush(fdopen(STDOUT_FILENO)) but realized that there are some
couplings made and that it would not have the right effect on every
platform I can test on.

Could somebody have a look at the code and unset the O_NONBLOCK and
fflush stdout appropriately before quitting? Here is a code that does
such a thing http://www.meme.com/soft/pushprog.c but that doesn't
involve the couplings nodejs contains which confused me.

Cheers!
Standa

PS: I worked around the problem by writing the contents into a file
explicitly which works fine for me for the time being...

Jérémy Lal

unread,
Feb 5, 2010, 5:13:09 AM2/5/10
to nod...@googlegroups.com
Hi,
using latest node_postgres add-on, when i run test.js
i get a seg fault.
I just wanted to know if someone else has the same problem.

Regards,
Jérémy.

signature.asc

Micheil Smith

unread,
Feb 5, 2010, 7:15:30 AM2/5/10
to nod...@googlegroups.com
Hi Jérémy,

Please move this to a new thread, rather then changing the topic on an existing thread.

Thanks,
Micheil Smith

BrandedCode.com

Micheil Smith

unread,
Feb 5, 2010, 7:16:37 AM2/5/10
to nodejs
Just a change back in thread title.

>  signature.asc
> < 1KViewDownload

Jérémy Lal

unread,
Feb 5, 2010, 7:19:35 AM2/5/10
to nod...@googlegroups.com
signature.asc

Micheil Smith

unread,
Feb 5, 2010, 8:17:49 AM2/5/10
to nod...@googlegroups.com
I think sys.debug() is sync, but I'm not sure on that.

- Micheil.

> --
> You received this message because you are subscribed to the Google Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com.
> To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.
>

Benjamin Thomas

unread,
Feb 5, 2010, 8:48:41 AM2/5/10
to nod...@googlegroups.com
On Fri, Feb 5, 2010 at 6:17 AM, Micheil Smith <mic...@brandedcode.com> wrote:
> I think sys.debug() is sync, but I'm not sure on that.

It is, but that isn't the issue here (as far as I can tell from the
authors posting). While that would solve the problem, the issue is
that the program will exit completely before all its output has been
written.

I have ran into this problem as well while using
process.createChildProcess(). The child will get the exit event
before that last data has been written to stdout from the child.

Even if the sys.puts is async, it seems useful to me that if you do
write something to stdout that it at least be guaranteed to be
written.

Tim Caswell

unread,
Feb 5, 2010, 10:39:33 AM2/5/10
to nod...@googlegroups.com
Correct, that's the behavior I see all the time too. About 20% of the time my programs will not output the last chunk of data to the terminal before they close. It's simply been an annoyance to me, but I would like to see it fixed somehow.

opichals

unread,
Feb 5, 2010, 1:47:54 PM2/5/10
to nodejs
Hi!

This is an essential feature of a well behaving application to
actually provide all stdout written data. If that were not the case it
would be unusable in typical unixy way, piping from one process to
another through the stdout/stdin channel.

Best Regards
Standa


On Feb 5, 4:39 pm, Tim Caswell <t...@creationix.com> wrote:
> Correct, that's the behavior I see all the time too. About 20% of the time my programs will not output the last chunk of data to the terminal before they close.  It's simply been an annoyance to me, but I would like to see it fixed somehow.
>
> On Feb 5, 2010, at 7:48 AM, Benjamin Thomas wrote:
>

opichals

unread,
Feb 5, 2010, 4:13:08 PM2/5/10
to nodejs
Here is a simple test patch I see the failures with http://gist.github.com/296245
.
Reply all
Reply to author
Forward
0 new messages