Hi Monks!
I'm facing a strange bug. Please consider the following code:
print("Before setting command: $path\n");
$cmd = "ldd $path";
print("Before running command\n");
($stdout, $stderr, $exit_status) = capture { system($cmd); };
print("After running command\n");
The output:
Before setting command: /proc/self/fd/1
Before running command
And it gets stuck. It continues running only after I click Ctrl+C. Then it will resume and continue running my script. The output looks like:
Before setting command: /proc/self/fd/1
Before running command
^CAfter running command
Note the
^C. Any other path works well.
Now the strange part. If I run
ldd /proc/self/fd/1 in the command line - it does not get stuck and it works (just prints:
ldd: /proc/self/fd/1: not regular file). And also, if I change the code to be:
print("Before setting command: $path\n");
$cmd = "$LDD $path";
print("Before running command\n");
$stdout = `$cmd`;
#($stdout, $stderr, $exit_status) = capture { system($cmd); };
print("After running command\n");
Then I get:
Before setting command: /proc/self/fd/1
Before running command
ldd: /proc/self/fd/1: not regular file
After running command
Which makes me believe that
Capture::Tiny getting stuck on this path.
Why does it happen? How should it be handled? If I could check if the path is dynamic, then I could just ignore this path. The question is, could it happen on other paths as well?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.