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

set socket as inheritable #190

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions _pydevd_bundle/pydevd_comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,11 @@ def start_client(host, port):

s = socket(AF_INET, SOCK_STREAM)

# Since python 3.4, sockets are by default non inheritable,
# inheritance must be set to true to allow applications to work with child processes
if hasattr(s, 'set_inheritable'):
s.set_inheritable(True)

# Set TCP keepalive on an open socket.
# It activates after 1 second (TCP_KEEPIDLE,) of idleness,
# then sends a keepalive ping once every 3 seconds (TCP_KEEPINTVL),
Expand Down
10 changes: 10 additions & 0 deletions tests_python/resources/_debugger_case_execv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import sys, os
import threading

print("break here")
if len(sys.argv) == 1:
os.execv(sys.executable, [sys.executable] + sys.argv + ["1"])

if len(sys.argv) == 2:
print("TEST SUCEEDED")

22 changes: 21 additions & 1 deletion tests_python/test_debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
IS_APPVEYOR, wait_for_condition, CMD_GET_FRAME, CMD_GET_BREAKPOINT_EXCEPTION,
CMD_THREAD_SUSPEND, CMD_STEP_OVER, REASON_STEP_OVER, CMD_THREAD_SUSPEND_SINGLE_NOTIFICATION,
CMD_THREAD_RESUME_SINGLE_NOTIFICATION, REASON_STEP_RETURN, REASON_STEP_RETURN_MY_CODE,
REASON_STEP_OVER_MY_CODE, REASON_STEP_INTO, CMD_THREAD_KILL, IS_PYPY, REASON_STOP_ON_START)
REASON_STEP_OVER_MY_CODE, REASON_STEP_INTO, CMD_THREAD_KILL, IS_PYPY, REASON_STOP_ON_START, CMD_THREAD_RUN)
from _pydevd_bundle.pydevd_constants import IS_WINDOWS, IS_PY38_OR_GREATER, \
IS_MAC
from _pydevd_bundle.pydevd_comm_constants import CMD_RELOAD_CODE, CMD_INPUT_REQUESTED
Expand Down Expand Up @@ -4201,6 +4201,26 @@ def test_frame_eval_mode_corner_case_many(case_setup, break_name):

writer.finished_ok = True


def test_execv(case_setup):
from tests_python.debugger_unittest import AbstractWriterThread
with case_setup.test_file('_debugger_case_execv.py') as writer:
break_line = writer.get_line_index_with_content('break here')
writer.write_add_breakpoint(break_line)

writer.write_make_initial_run()

hit = writer.wait_for_breakpoint_hit()
writer.write_run_thread(hit.thread_id)

writer.wait_for_message(CMD_THREAD_RUN, expect_xml=False)

hit = writer.wait_for_breakpoint_hit()
writer.write_run_thread(hit.thread_id)

writer.finished_ok = True


# Jython needs some vars to be set locally.
# set JAVA_HOME=c:\bin\jdk1.8.0_172
# set PATH=%PATH%;C:\bin\jython2.7.0\bin
Expand Down