digitalmars.D.learn - Behaves different on my osx and linux machines
- =?UTF-8?Q?Christian_K=C3=B6stlin?= (56/56) Dec 21 2023 I have this somehow reduced program that behaves differently on osx and
- Kagamin (22/22) Dec 22 2023 Add more debugging?
- Christian =?UTF-8?B?S8O2c3RsaW4=?= (26/48) Dec 22 2023 Thanks for the suggestion. But it still behaves the same:
- Kagamin (24/24) Dec 27 2023 Maybe write and read lock each other, try to use puts:
- Kagamin (1/1) Dec 27 2023 Maybe you're not supposed to print text while reading?
- Christian =?UTF-8?B?S8O2c3RsaW4=?= (6/7) Dec 27 2023 In parallel I have contacted schveiguy on discord and he found
- Steven Schveighoffer (7/12) Dec 27 2023 Finally had some spare time, and created the issue:
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.
Dec 21 2023
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"); ```
Dec 22 2023
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 ```
Dec 22 2023
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"); ```
Dec 27 2023
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
Dec 27 2023
On Wednesday, 27 December 2023 at 14:38:38 UTC, Christian Köstlin wrote:On Wednesday, 27 December 2023 at 14:03:06 UTC, Kagamin wrote:Finally had some spare time, and created the issue: https://issues.dlang.org/show_bug.cgi?id=24305 Might I say, this is a symptom of depending on C for buffered i/o, and I wish we didn't. -SteveMaybe 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/.
Dec 27 2023