-
-
Notifications
You must be signed in to change notification settings - Fork 48
Description
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:
TextCopy/src/TextCopy/BashRunner.cs
Line 48 in 701c644
| 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:
- I could support it only for the async APIs, and then use the CancellationToken that's already there to control
Process.WaitForExit(moving toProcess.WaitForExitAsync). - I could provide some optional configuration option that would be passed to the
SetTextmethod (and possiblyGetText, just for parity?). Either passing just a timespan/int timeout, or some ClipboardConfiguration class. - 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.