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

Use grep without perl option #144

Merged
merged 2 commits into from
Jul 26, 2024
Merged

Use grep without perl option #144

merged 2 commits into from
Jul 26, 2024

Conversation

chorry
Copy link

@chorry chorry commented Jul 16, 2024

Used docker run --rm php php -r 'foreach (range(0,30000) as $i) {echo $i."\n"; sleep(1);}' as a test process

Build from default dockerfile as docker build -t phpspy-test .

➜  phpspy git:(master) docker run --pid=host --privileged --cap-add SYS_PTRACE --rm phpspy-test phpspy/phpspy --pid=2701841 
grep: unrecognized option: P
BusyBox v1.36.1 (2024-06-10 07:11:47 UTC) multi-call binary.

Usage: grep [-HhnlLoqvsrRiwFE] [-m N] [-A|B|C N] { PATTERN | -e PATTERN... | -f FILE... } [FILE]...
....
        -f FILE Read pattern from file
xargs: 'strings' terminated by signal 13
get_php_version: Could not detect PHP version

Patched version:

➜  phpspy git:(master) docker run --pid=host --privileged --cap-add SYS_PTRACE --rm phpspy-patched phpspy/phpspy --pid=2701841 -l 1
0 sleep <internal>:-1
1 <main> <internal>:-1

@adsr
Copy link
Owner

adsr commented Jul 16, 2024

Hi, thanks for the PR. I don't think this will work with GNU grep (see test failures). Can you try changing both grep -os to grep -Eo and the \d metacharacters to [0-9]? I think BusyBox, BSD, and GNU grep all support -E (POSIX extended regex).

@adsr adsr merged commit f06f466 into adsr:master Jul 26, 2024
1 check passed
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

Successfully merging this pull request may close these issues.

2 participants