@@ -1208,6 +1208,34 @@ def f():
12081208 self .assertEqual (err , b'' )
12091209
12101210
1211+ @skip_unless_reliable_fork
1212+ def test_native_id_after_fork (self ):
1213+ script = """if True:
1214+ import threading
1215+ import os
1216+ from test import support
1217+
1218+ parent_thread_native_id = threading.current_thread().native_id
1219+ print(parent_thread_native_id, flush=True)
1220+ assert parent_thread_native_id == threading.get_native_id()
1221+ childpid = os.fork()
1222+ if childpid == 0:
1223+ print(threading.current_thread().native_id, flush=True)
1224+ assert threading.current_thread().native_id == threading.get_native_id()
1225+ else:
1226+ try:
1227+ assert parent_thread_native_id == threading.current_thread().native_id
1228+ assert parent_thread_native_id == threading.get_native_id()
1229+ finally:
1230+ support.wait_process(childpid, exitcode=0)
1231+ """
1232+ rc , out , err = assert_python_ok ('-c' , script )
1233+ self .assertEqual (rc , 0 )
1234+ self .assertEqual (err , b"" )
1235+ native_ids = out .strip ().splitlines ()
1236+ self .assertEqual (len (native_ids ), 2 )
1237+ self .assertNotEqual (native_ids [0 ], native_ids [1 ])
1238+
12111239class ThreadJoinOnShutdown (BaseTestCase ):
12121240
12131241 def _run_and_join (self , script ):
0 commit comments