in reply to Running a perl script as a system command in another thread hangs while main thread reading from STDIN
I see no difference between the two runs of the program;
C:\test>junk49 ### Running a regular command ### 0s : Thread 0 - > Creating threads 0s : Thread 1 - Created 0s : Thread 2 - Created 0s : Thread 3 - Created 1s : Thread 0 - All Threads created 1s : Thread 0 - > Waiting for input now. All threads should finish now + without pressing enter 3s : Thread 1 - Starting 'echo hello world' 3s : Thread 2 - Starting 'echo hello world' 3s : Thread 3 - Starting 'echo hello world' 3s : Thread 1 - Finished the command: hello world 3s : Thread 2 - Finished the command: hello world 3s : Thread 3 - Finished the command: hello world 10s : Thread 0 - > Input received, all done 10s : Thread 0 - All Threads joined C:\test>junk49 1 ### Running a perl script ### 0s : Thread 0 - > Creating threads 0s : Thread 1 - Created 0s : Thread 2 - Created 0s : Thread 3 - Created 1s : Thread 0 - All Threads created 1s : Thread 0 - > Waiting for input now. All threads should finish now + without pressing enter 3s : Thread 1 - Starting 'perl -e "print \"hello world\""' 3s : Thread 2 - Starting 'perl -e "print \"hello world\""' 3s : Thread 3 - Starting 'perl -e "print \"hello world\""' 3s : Thread 1 - Finished the command: hello world 3s : Thread 2 - Finished the command: hello world 3s : Thread 3 - Finished the command: hello world 14s : Thread 0 - > Input received, all done 14s : Thread 0 - All Threads joined
The threads won't terminate until they are joined; and they won't be joined until the code moves past <STDIN>; to the join loop.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Running a perl script as a system command in another thread hangs while main thread reading from STDIN
by rmahin (Scribe) on Sep 30, 2014 at 01:04 UTC | |
by BrowserUk (Patriarch) on Sep 30, 2014 at 01:11 UTC | |
by rmahin (Scribe) on Sep 30, 2014 at 01:16 UTC | |
by BrowserUk (Patriarch) on Sep 30, 2014 at 02:40 UTC | |
by rmahin (Scribe) on Sep 30, 2014 at 16:39 UTC | |
|