diff --git a/_pydevd_bundle/pydevd_comm.py b/_pydevd_bundle/pydevd_comm.py index 08d18386c..9e592a890 100644 --- a/_pydevd_bundle/pydevd_comm.py +++ b/_pydevd_bundle/pydevd_comm.py @@ -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), diff --git a/tests_python/resources/_debugger_case_execv.py b/tests_python/resources/_debugger_case_execv.py new file mode 100644 index 000000000..e5912b133 --- /dev/null +++ b/tests_python/resources/_debugger_case_execv.py @@ -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") + diff --git a/tests_python/test_debugger.py b/tests_python/test_debugger.py index e6b7fd892..2dd3b8cbb 100644 --- a/tests_python/test_debugger.py +++ b/tests_python/test_debugger.py @@ -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 @@ -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