I was trying to check response messages written in perl which takes requests through Amazon API and returns responses..How to run parallel fork as single thread in perl?. I'm using LWP::UserAgent module and I want to debug HTTP requests.
-
What platform are you working on? – Borodin Jun 17 '15 at 12:00
1 Answers
As a word of warning - threads and forks are different things in perl. Very different.
However the long and short of it is - you can't, at least not trivially - a fork is a separate process. It actually happens when you run -any- external command in perl, it's just by default perl sits and waits for that command to finish and return output.
However if you've got access to the code, you can amend it to run single threaded - sometimes that's as simple as reducing the paralleism with a config parameter. (In fact quite often - debugging parallel code is a much more complicated task than sequential, so getting it working before running parallel is really important).
You might be able to embed a waitpid
into your primary code so you've only got one thing running at once. Without a code example though, it's impossible to say for sure.

- 52,974
- 7
- 60
- 101
-
Well, Thanks a lot for the info. I narrowed down the number of forks to 1. That sort of helped me. – Vijay Kumar Jun 18 '15 at 17:17