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

Retry interrupted std stream read/write calls. #651

Conversation

LostBranch5502
Copy link
Contributor

The Hashlink profiler causes some Linux system calls to be interrupted. Previously, error handling was added for std/file.c read/write operations. However, the read/write calls made by sys.io.Process use instead the unistd read/write functions which are also affected by the interrupts.

This pull request extends the previously introduced error handling also to the unistd read/write calls in std/process.c.

The behaviour can be tested with the following program, which uses the stdout, stderr and stdin streams via sys.io.Process:

import sys.io.Process;

class Main
{
    static public function main():Void
    {
        var cat = new Process('cat');
        cat.stdin.writeString('Text to stdout\n');
        trace(cat.stdout.readLine());
        cat = new Process('cat 1>&2');
        cat.stdin.writeString('Text to stderr\n');
        trace(cat.stderr.readLine());
    }
}

Previously, when running with the profiler hl --profile 1000 test.hl the test program fails with the exception:

Uncaught exception: Eof
Called from haxe.io.Input.readLine(.../haxe-4.3.3-linux64/haxe_20231117191750_de28889/std/haxe/io/Input.hx:189)
Called from $Main.main(Main.hx:9)
Called from .init(?:1)

With the proposed changes the test program runs normally and can be profiled.

@ncannasse ncannasse merged commit fc4a2db into HaxeFoundation:master Feb 7, 2024
9 checks passed
GlassySundew pushed a commit to GlassySundew/hashlink that referenced this pull request May 11, 2024
RandomityGuy pushed a commit to RandomityGuy/hashlink that referenced this pull request Jun 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants