Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading from $*IN in a sub process' start {} hangs #4258

Closed
p6rt opened this issue May 21, 2015 · 5 comments
Closed

Reading from $*IN in a sub process' start {} hangs #4258

p6rt opened this issue May 21, 2015 · 5 comments
Labels

Comments

@p6rt
Copy link

p6rt commented May 21, 2015

Migrated from rt.perl.org#125230 (status was 'resolved')

Searchable as RT125230$

@p6rt
Copy link
Author

p6rt commented May 21, 2015

From tony.odell@live.com

Encountered the following problem implementing Event​::Emitter between processes. This code will run forever as .read(1) forever reads nothing from $*IN

#!/usr/bin/env perl6

my $p = Proc​::Async.new('perl6', '-e', '
  await start {
 
  my $d = $*IN.read(1);
 
  while $d.elems == 0 {
 
  $d = $*IN.read(1);
 
  }
 
  $d.say;
 
  };', :w);

my $r = $p.start;

$p.write("0".encode);

await $r;


ACTUAL​:
Sub process 'reads' an empty Buf forever

EXPECTED​:
Sub process eventually 'reads' a Buf containing 1 byte

tony-o
 

@p6rt
Copy link
Author

p6rt commented May 27, 2015

From @hoelzro

I can't say for sure, but this sounds very similar to this MoarVM issue​: MoarVM/MoarVM#165

Have you tried this on MoarVM vs JVM?

On Thu May 21 12​:50​:18 2015, tony.odell@​live.com wrote​:

Encountered the following problem implementing Event​::Emitter between
processes. This code will run forever as .read(1) forever reads
nothing from $*IN

#!/usr/bin/env perl6

my $p = Proc​::Async.new('perl6', '-e', '
await start {

my $d = $*IN.read(1);

while $d.elems == 0 {

$d = $*IN.read(1);

}

$d.say;

};', :w);

my $r = $p.start;

$p.write("0".encode);

await $r;

----------------------------------------------------------

ACTUAL​:
Sub process 'reads' an empty Buf forever

EXPECTED​:
Sub process eventually 'reads' a Buf containing 1 byte

tony-o

@p6rt
Copy link
Author

p6rt commented May 27, 2015

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Sep 12, 2017

From @jnthn

On Thu, 21 May 2015 12​:50​:18 -0700, tony.odell@​live.com wrote​:

Encountered the following problem implementing Event​::Emitter between
processes. This code will run forever as .read(1) forever reads
nothing from $*IN

#!/usr/bin/env perl6

my $p = Proc​::Async.new('perl6', '-e', '
await start {

my $d = $*IN.read(1);

while $d.elems == 0 {

$d = $*IN.read(1);

}

$d.say;

};', :w);

my $r = $p.start;

$p.write("0".encode);

await $r;

----------------------------------------------------------

ACTUAL​:
Sub process 'reads' an empty Buf forever

EXPECTED​:
Sub process eventually 'reads' a Buf containing 1 byte

This was one of the many cases of I/O handles not working across different threads, which was fixed earlier on this year. Output is now​:

Buf[uint8]​:0x<30>

Various tests were added covering this, as it showed up in various other tickets, so will mark this issue resolved.

@p6rt
Copy link
Author

p6rt commented Sep 12, 2017

@jnthn - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Sep 12, 2017
@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant