Re: Behaves different on my osx and linux machines

2023-12-27 Thread Christian Köstlin via Digitalmars-d-learn

On Wednesday, 27 December 2023 at 14:03:06 UTC, Kagamin wrote:

Maybe you're not supposed to print text while reading?


In parallel I have contacted schveiguy on discord and he found 
the culprid. But we do not have a solution yet. It probably will 
result in a bugreport at https://issues.dlang.org/.


Kind regards,
Christian




Re: Behaves different on my osx and linux machines

2023-12-27 Thread Kagamin via Digitalmars-d-learn

Maybe you're not supposed to print text while reading?


Re: Behaves different on my osx and linux machines

2023-12-27 Thread Kagamin via Digitalmars-d-learn

Maybe write and read lock each other, try to use puts:
```
  bool done = false;
  while (!done) {
  puts("1");
  auto result = ["echo", "Hello World"].execute;
  if (result.status != 0)
  {
  writeln(2);
  throw new Exception("echo failed");
  }
  puts("2");
  writeln(result.output);
  puts("3");
  receiveTimeout(dur!"msecs"(-1),
(LinkTerminated t) {
writeln("Done");
done = true;
},
  );
  writeln(4);
  }
  writeln("ByeBye");
```


Re: Behaves different on my osx and linux machines

2023-12-22 Thread Christian Köstlin via Digitalmars-d-learn

On Friday, 22 December 2023 at 15:02:42 UTC, Kagamin wrote:

Add more debugging?
```
 bool done = false;
 while (!done) {
 writeln(1);
 auto result = ["echo", "Hello World"].execute;
 if (result.status != 0)
 {
 writeln(2);
 throw new Exception("echo failed");
 }
 writeln(result.output);
 receiveTimeout(dur!"msecs"(-1),
   (LinkTerminated t) {
   writeln("Done");
   done = true;
   },
 );
 writeln(3);
 }
 writeln("ByeBye");
```

Thanks for the suggestion. But it still behaves the same:
Output:
```
 Running vibe-io
1
Please enter something:
asdf
You entered asdf

Please enter something:
Hello World

3
1
asdf
You entered asdf

Please enter something:
Hello World

3
1
qwer
You entered qwer

Please enter something:
Hello World

3
1
```


Re: Behaves different on my osx and linux machines

2023-12-22 Thread Kagamin via Digitalmars-d-learn

Add more debugging?
```
 bool done = false;
 while (!done) {
 writeln(1);
 auto result = ["echo", "Hello World"].execute;
 if (result.status != 0)
 {
 writeln(2);
 throw new Exception("echo failed");
 }
 writeln(result.output);
 receiveTimeout(dur!"msecs"(-1),
   (LinkTerminated t) {
   writeln("Done");
   done = true;
   },
 );
 writeln(3);
 }
 writeln("ByeBye");
```


Behaves different on my osx and linux machines

2023-12-21 Thread Christian Köstlin via Digitalmars-d-learn
I have this somehow reduced program that behaves differently on osx and 
linux.



```d
void stdioMain()
{
import std.stdio : readln, writeln;
import std.concurrency : spawnLinked, receive, receiveTimeout, 
LinkTerminated;

import std.variant : Variant;
import std.string : strip;
import std.process : execute;
import core.time : dur;
auto input = spawnLinked(() {
string getInput() {
writeln("Please enter something:");
return readln().strip();
}
string line = getInput();
while (line != "quit")
{
writeln("You entered ", line);
line = getInput();
}
});

bool done = false;
while (!done) {
auto result = ["echo", "Hello World"].execute;
if (result.status != 0)
{
throw new Exception("echo failed");
}
writeln(result.output);
receiveTimeout(dur!"msecs"(-1),
  (LinkTerminated t) {
  writeln("Done");
  done = true;
  },
);
}
writeln("ByeBye");
}

void main(string[] args)
{
stdioMain();
}
`

It should just read from stdin in one separate thread and on the main 
thread it just executes one `echo` after the other (and tries to find 
out, if the other thread finished).


In linux this behaves as expected, meaning it prints a lot of hello worlds.

In osx on the other hand it prints 'please enter something', waits for 
my input, prints it, and outputs one hello world.


What did I do wrong?

Kind regards,
Christian

p.s.: i am using ldc-1.35.0 osx version is 13.6.