Yes, you're right about the unnecessary newlines. I fixed the newline where it feeds the file one line at a time to the child. The perl absolutely reaches "END".

test.js is three simple lines:

var foo=0; var bar=1; var baz=2;

And I can type these in, one at a time, into the running javascript program from the command line:

$ js js> load('jslint.js'); var foo=0; var bar=1; var baz=3; END jslint: No problems found. $

If I drop warns in:

open FILE, '<', "test.js"; while (<FILE>) { warn "printing $_"; print $JSWRITE "$_"; } close(FILE); warn "printing END\n"; print $JSWRITE "END\n";

I see:

$ ./jslint.pl printing var foo=0; printing var bar=1; printing var baz=3; printing END

And strace shows this:

... write(4, "load(\'jslint.js\');\n", 19) = 19 open("test.js", O_RDONLY) = 3 ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff8d5e9440) = -1 ENOTTY (I +nappropriate ioctl for device) lseek(3, 0, SEEK_CUR) = 0 fstat(3, {st_mode=S_IFREG|0664, st_size=33, ...}) = 0 fcntl(3, F_SETFD, FD_CLOEXEC) = 0 read(3, "var foo=0;\nvar bar=1;\nvar baz=3;"..., 4096) = 33 write(2, "printing var foo=0;\n", 20printing var foo=0; ) = 20 write(4, "var foo=0;\n", 11) = 11 write(2, "printing var bar=1;\n", 20printing var bar=1; ) = 20 write(4, "var bar=1;\n", 11) = 11 write(2, "printing var baz=3;\n", 20printing var baz=3; ) = 20 write(4, "var baz=3;\n", 11) = 11 read(3, "", 4096) = 0 close(3) = 0 write(2, "printing END\n", 13printing END ) = 13 write(4, "END\n", 4) = 4 close(4) = 0 read(5, <unfinished ...>

Which, if I remove reading from $JSREAD, becomes:

write(4, "load(\'jslint.js\');\n", 19) = 19 open("test.js", O_RDONLY) = 3 ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff38afb950) = -1 ENOTTY (I +nappropriate ioctl for device) lseek(3, 0, SEEK_CUR) = 0 fstat(3, {st_mode=S_IFREG|0664, st_size=33, ...}) = 0 fcntl(3, F_SETFD, FD_CLOEXEC) = 0 read(3, "var foo=0;\nvar bar=1;\nvar baz=3;"..., 4096) = 33 write(2, "printing var foo=0;\n", 20printing var foo=0; ) = 20 write(4, "var foo=0;\n", 11) = 11 write(2, "printing var bar=1;\n", 20printing var bar=1; ) = 20 write(4, "var bar=1;\n", 11) = 11 write(2, "printing var baz=3;\n", 20printing var baz=3; ) = 20 write(4, "var baz=3;\n", 11) = 11 read(3, "", 4096) = 0 close(3) = 0 write(2, "printing END\n", 13printing END ) = 13 write(4, "END\n", 4) = 4 close(4) = 0 close(5) = 0 wait4(8790, <unfinished ...>

In reply to Re^4: Diagnosing blocking io (or: finding the WHY of my Open2 woes). by Socrates
in thread Diagnosing blocking io (or: finding the WHY of my Open2 woes). by Socrates

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.