Skip to content

Configuring the process timeout on BashRunner #830

@waf

Description

@waf

Thanks for creating TextCopy, it's a great library. I use it in my CSharpRepl project, and it's worked well.

Is the feature request related to a problem: Yes

I'd like to be able to configure the process timeout in BashRunner. I recently had a bug report from a user about a timeout on Linux (ref waf/CSharpRepl#327), and I see the process timeout is set to 500ms in BashRunner:

var result = process.WaitForExit(500);

For reference, the stack trace reported by the user was:

System.Exception: Process timed out. Command line: bash -c "cat /tmp/tmpWDKMZj.tmp | xsel -i --clipboard ".
Output: 
Error: 
   at BashRunner.Run(String commandLine) in /_/src/TextCopy/BashRunner.cs:line 32
   at LinuxClipboard.InnerSetText(String tempFileName) in /_/src/TextCopy/LinuxClipboard_2.1.cs:line 42
   at LinuxClipboard.SetTextAsync(String text, CancellationToken cancellation) in /_/src/TextCopy/LinuxClipboard_2.1.cs:line 22
   ... stack frames from application ...

I'm happy to adjust my application's usage if there's a better way of handling this.

Describe the solution

I can provide a PR for this feature, but there are a few different options for implementing it and I'm looking for guidance:

  1. I could support it only for the async APIs, and then use the CancellationToken that's already there to control Process.WaitForExit (moving to Process.WaitForExitAsync).
  2. I could provide some optional configuration option that would be passed to the SetText method (and possibly GetText, just for parity?). Either passing just a timespan/int timeout, or some ClipboardConfiguration class.
  3. Similar to above, but support passing the configuration option to the Clipboard's instance constructor instead.

In my opinion, Option 1 is the best, but Option 2 or 3 would be good if there are other configuration scenarios you'd like to support. Thanks again for creating such a useful library.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions