dty63504 2014-10-14 05:20
浏览 442
已采纳

Go中的os.StartProcess为什么将子进程的进程组ID设置为等于子进程pid

The golang library function os.StartProcess() calls setpgid(0,0) in the child process after forking.

It does this on the "linux" and "bsd" configurations, sources here: http://golang.org/src/pkg/syscall/exec_bsd.go?h=SYS_SETPGID#L105 http://golang.org/src/pkg/syscall/exec_linux.go?h=SYS_SETPGID#L117

I noticed in the past that the OSX Foundation library NSTask - (void)launch method does the same thing (undocumented). At that time it seemed like an annoyance as it makes it harder to manage trees of processes.

What is the benefit of these libraries doing this automatically?

  • 写回答

1条回答 默认 最新

  • duanjiwu0324 2014-10-14 07:19
    关注

    The short answer is that it doesn't. It only changes the group if attr.Sys.Setpgid is true. This is to have feature parity with the system's API. It is not even an option on all OSes

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 gradio的web端页面格式不对的问题
  • ¥15 求大家看看Nonce如何配置
  • ¥15 Matlab怎么求解含参的二重积分?
  • ¥15 苹果手机突然连不上wifi了?
  • ¥15 cgictest.cgi文件无法访问
  • ¥20 删除和修改功能无法调用
  • ¥15 kafka topic 所有分副本数修改
  • ¥15 小程序中fit格式等运动数据文件怎样实现可视化?(包含心率信息))
  • ¥15 如何利用mmdetection3d中的get_flops.py文件计算fcos3d方法的flops?
  • ¥40 串口调试助手打开串口后,keil5的代码就停止了