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

byteStringOutput breaks withProcessTerm #84

Open
SmartHypercube opened this issue Sep 9, 2024 · 2 comments
Open

byteStringOutput breaks withProcessTerm #84

SmartHypercube opened this issue Sep 9, 2024 · 2 comments

Comments

@SmartHypercube
Copy link

  1. byteStringOutput blocks and waits for the entire output in ssCreate.
  2. startProcess calls ssCreate.
  3. So startProcess blocks if I use byteStringOutput. (Well, this is already bad.)
  4. withProcessTerm is broken because it blocks in the startProcess stage. The user-provided action can only run after stdout is closed.

This bug makes this library unsuitable for almost all my use cases :( Since I often need to capture the output while setting some kind of timeout on the subprocess. Sadly I'm not sure how it can be fixed without a major redesign.

(Sorry if this is a duplicate of other open issues. I checked them but I'm not sure.)

@sol
Copy link
Contributor

sol commented Sep 9, 2024

@SmartHypercube can you give exact steps on how to reproduce this?

@SmartHypercube
Copy link
Author

#!/usr/bin/env stack
-- stack script --resolver lts-22.33 --package typed-process
import Control.Concurrent
import System.Process.Typed

main :: IO ()
main = do
    withProcessTerm (setStdout byteStringOutput $ proc "sleep" ["10"]) $ \_ -> do
        print 1
        threadDelay 5_000_000
        print 2

Expected behavior: sleep is killed after 5 seconds.
Actual behavior: The program runs for 10 seconds.

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

No branches or pull requests

2 participants