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

Zombie tcpdump Process After Using sniff() on pcap with Filter #4512

Open
romanhu opened this issue Aug 28, 2024 · 2 comments
Open

Zombie tcpdump Process After Using sniff() on pcap with Filter #4512

romanhu opened this issue Aug 28, 2024 · 2 comments
Labels

Comments

@romanhu
Copy link

romanhu commented Aug 28, 2024

Brief description

When using Scapy's sniff() function to read from a pcap file, a zombie tcpdump process is left behind if the filter argument is set to a non-None value. This issue occurs consistently when a BPF filter is applied during packet sniffing, leading to potential resource leakage and system instability due to the accumulation of zombie processes.

Scapy version

2.5

Python version

3.11

Operating system

Linux Debian 6.1.99-1

Additional environment information

No response

How to reproduce

  1. Start scapy interactive console
  2. Call sniff(offline="/path/to/any.pcap", filter="")
  3. In another terminal execute ps x | grep tcpdump

Actual result

The ps command lists the tcpdump process with a <defunct> status, indicating that the process has become a zombie. This status means the process has completed execution but remains in the process table because its parent process has not yet read its exit status.

Expected result

ps should not show any tcpdump processes if sniff is done reading the pcap file

Related resources

No response

@romanhu romanhu changed the title tcpdump zombie process after usiing sniff on pcap with filter Zombie tcpdump Process After Using sniff() on pcap with Filter Aug 28, 2024
@p-l- p-l- added the bug label Aug 28, 2024
@p-l-
Copy link
Member

p-l- commented Aug 28, 2024

Thanks for this report. You're right. Also, Python reports this (at least Python 3.12):

/usr/lib/python3.12/subprocess.py:1127: ResourceWarning: subprocess 123456 is still running
  _warn("subprocess %s is still running" % self.pid,
ResourceWarning: Enable tracemalloc to get the object allocation traceback

@p-l-
Copy link
Member

p-l- commented Aug 28, 2024

An option to patch this would be to prevent tcpdump() from being used with getfd=True without using a with pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants