2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

fork した子プロセスの終了時に at_exit を実行しない

Last updated at Posted at 2019-01-24

問題

Sucker Punch を使っているアプリ内で、Kernel.#fork を使うと何故かすべてのキューが終了してしまった。

原因

Sucker Punch がキューのシャットダウンを at_exit に書いており、
Kernel.#fork で作成した子プロセスが終了すると at_exit が実行されることが原因だった。

対応

Kernel.#exit! のドキュメントに書いてあった。

exit! は exit とは違って、例外処理などは一切行ないません。 Kernel.#fork の後、子プロセスを終了させる時などに用いられます。

pid = fork do
  # 子プロセスの処理
  exit!
end

Process.waitpid(pid)

forkat_exit のドキュメントに書かれていなかったので結構彷徨ってしまった…。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?