Repository navigation
browseros: subprocess の start_new_session と process_group を posix_spawn の setsid・setpgroup で渡す - #3
Merged
nakedtatsuya merged 1 commit intoNov 1, 2026
Conversation
…wn の setsid・setpgroup で渡す jupyter_client はカーネルを start_new_session=True で起こす(サーバーに届いた SIGINT をカーネルへ漏らさないため)。 BrowserOS の libc の posix_spawn は POSIX_SPAWN_SETSID・POSIX_SPAWN_SETPGROUP を持ち、カーネルの setsid・setpgid も 本物なので、_posixsubprocess が子で setsid() / setpgid() を呼ぶのと同じ結果を posix_spawn の属性で作る。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
BrowserOS の
subprocessでstart_new_session=Trueとprocess_group=を使えるようにします。jupyter_client はカーネルを
start_new_session=Trueで起動します(サーバーに届いた SIGINT がカーネルへ漏れないようにし、割り込みはカーネルのプロセスグループだけへ送るため)。これまで_browseros_subprocess.pyはこの 2 つをEOPNOTSUPPで断っていたため、BrowserOS の中のjupyter labからカーネルを起動できませんでした。BrowserOS の libc の
posix_spawnはPOSIX_SPAWN_SETSID・POSIX_SPAWN_SETPGROUPを持ち、カーネルの setsid(2)・setpgid(2) も本物です。そこで_posixsubprocessが子でsetsid()/setpgid()を呼ぶのと同じ結果を、os.posix_spawnのsetsid/setpgroupで作ります。確かめたこと
Node 上の BrowserOS(publish 済みの python.wasm に、このファイルを
PYTHONPATHの先頭で重ねたもの)で:subprocess.run(..., start_new_session=True)の子:getpid() == getsid(0)もgetpid() == getpgrp()も Trueprocess_group=0の子: 新しいグループの頭(セッションは親のまま)jupyter labからカーネルを起動し、セルの実行・/api/kernels/<id>/interrupt(sleep・純 Python のループ・子プロセス待ちのいずれも KeyboardInterrupt)・再起動が通る同じ確かめを Progate/packages の
browser-python/src/subprocess.test.tsに足します。🤖 Generated with Claude Code