option to not override signal handler
維護者通常 2 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
從 ipykernel/kernelbase.py 中的 pre_handler_hook 開始,追蹤 dispatch_shell 如何呼叫它。確定嵌入式應用程式如何選擇不取代其 SIGINT 處理常式,然後驗證自訂處理常式仍保持不變,同時核心的正常訊號處理仍能正常運作。
由索引模型根據 Issue 內容生成。
描述
See also https://github.com/jupyter/qtconsole/issues/490
Hey there,
how can I embed qtconsole into an application without it overriding my own application's custom sigint handler?
Assume you have code that does
std::signal(SIGINT, &handleSigInt);
...
// do not initialize signal handlers
const auto initsigs = 0;
Py_InitializeEx(initsigs);
Then it is embedding qtconsole eventually, but at that point the sigint handler will be unset:
Thread 1 "QiTissue" hit Breakpoint 3, __interceptor_sigaction (signum=2, act=0x7fffffff8a60, oldact=0x7fffffff8b00)
at /build/gcc/src/gcc/libsanitizer/sanitizer_common/sanitizer_signal_interceptors.inc:55
55 in /build/gcc/src/gcc/libsanitizer/sanitizer_common/sanitizer_signal_interceptors.inc
(gdb) bt
#0 __interceptor_sigaction(int, __sanitizer::__sanitizer_sigaction const*, __sanitizer::__sanitizer_sigaction*)
(signum=2, act=0x7fffffff8a60, oldact=0x7fffffff8b00)
at /build/gcc/src/gcc/libsanitizer/sanitizer_common/sanitizer_signal_interceptors.inc:55
#1 0x00007fff5c055f0f in PyOS_setsig (sig=sig@entry=2, handler=handler@entry=0x7fff5c0b6fec <signal_handler>)
at Python/pylifecycle.c:2536
#2 0x00007fff5c0b849f in signal_signal_impl
(module=<optimized out>, handler=<built-in method default_int_handler of module object at remote 0x7fff51eeaa40>, signalnum=2) at ./Modules/signalmodule.c:505
#3 signal_signal (module=<optimized out>, args=<optimized out>, nargs=<optimized out>)
at ./Modules/clinic/signalmodule.c.h:141
#4 0x00007fff5bf7bbf8 in cfunction_vectorcall_FASTCALL
(func=<built-in method signal of module object at remote 0x7fff51eeaa40>, args=0x7fff58a24a88, nargsf=<optimized out>, kwnames=<optimized out>) at Objects/methodobject.c:426
or in python terms:
(gdb) py-bt
Traceback (most recent call first):
<built-in method signal of module object at remote 0x7fff51eeaa40>
File "/usr/lib/python3.9/signal.py", line 47, in signal
handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
File "/home/milian/.local/lib/python3.9/site-packages/ipykernel/kernelbase.py", line 280, in pre_handler_hook
self.saved_sigint_handler = signal(SIGINT, default_int_handler)
File "/home/milian/.local/lib/python3.9/site-packages/ipykernel/kernelbase.py", line 257, in dispatch_shell
self.pre_handler_hook()
the kernelbase.py code seems to reset the signal handler unconditionally to some default which is highly unexpected to me:
def pre_handler_hook(self):
"""Hook to execute before calling message handler"""
# ensure default_int_handler during handler call
self.saved_sigint_handler = signal(SIGINT, default_int_handler)
Is there a way to prevent this from happening?
- 主要語言
- Python
- 星號
- 734
- 分支
- 412
- 平均合併
- 1 天 10 小時
- 30 天內合併 PR
- 12
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
ipython/ipykernel 的其他 Issue
-
難度 1/5 1 小時以內 新手友好度 72/100
維護者通常 2 天內回覆
-
難度 4/5 3-5 天 新手友好度 35/100
ipython/ipykernel#1569 · 2 則留言 ·
維護者通常 2 天內回覆
-
難度 4/5 3-5 天 新手友好度 48/100
維護者通常 2 天內回覆
-
難度 4/5 3-5 天 新手友好度 68/100
ipython/ipykernel#1554 · 1 則留言 ·
維護者通常 2 天內回覆
-
Interrupt on swallowed `KeyboardInterrupt` exceptions (`SIGINT`) when pressing twice (within 5 seconds)可能重新可做 @Carreau 於 42 天前認領,目前沒有進行中的 PR。 未關閉
ipython/ipykernel#1550 · 1 則留言 · 1 個 reaction · 已指派 1 人 ·
維護者通常 2 天內回覆
查看 ipython/ipykernel 的全部 Issue
相似的 Issue
-
Harmony OPeNDAP SubSetter (HOSS) Geographic LARC_CLOUD PREFIRE_SAT2_AUX-SAT R01 production
難度 2/5 1-3 小時 新手友好度 68/100
nasa/harmony-autotester#245 ·
-
feature
難度 2/5 1-3 小時 新手友好度 66/100
-
L: github:actions L: php:composer
難度 2/5 1-3 小時 新手友好度 88/100
dependabot/dependabot-core#16493 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 92/100
DataTalksClub/machine-learning-zoomcamp#730 ·
維護者通常 2 天內回覆
-
難度 2/5 1-3 小時 新手友好度 82/100
維護者通常 4 天內回覆