Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Docker Container Started With Docker-Compose and <STDIN>

by roboticus (Chancellor)
on Sep 12, 2019 at 17:06 UTC ( [id://11106080]=note: print w/replies, xml ) Need Help??


in reply to Docker Container Started With Docker-Compose and <STDIN>

gflohr:

Unless you explicitly close it, you do have an STDIN available, and the script is hanging because it's waiting for input that'll never arrive.

If the script is yours or you can change it, I'd probably try:

  • Looking for an environment variable that can indicate whether you're in the Docker container and use it to bail out of your program, or
  • Use alarm() to add a timeout for user input so it can't hang indefinitely.

If the script isn't yours, but you're using fork() to invoke the script, then you could try duplicating the STDIN stream and closing it before forking, so the child script won't have an open STDIN. That should make it immediately return with undef in $input. (That may require some jiggery-pokery with IO::Handle or maybe a double-fork, where the child of the initial fork can close its STDIN and then fork to the script you want to run.)

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11106080]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-03-29 10:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found