fork/exec /bin/bash: operation not permitted

1,421 views
Skip to first unread message

Russtopia

unread,
Aug 7, 2019, 11:55:47 PM8/7/19
to golang-nuts
Hi all,

I'm trying to use the technique here

.. to ensure all children/grandchildren of my exec of /bin/bash die along with it, but I am getting the above 'operation not permitted' error when trying to Start(). It works fine without Setpgid set, but when my /bin/bash dies, any background children spawned from it are left running, adopted by init (pid 1).

Any idea why setting syscall.SysProcAttr{Setpgid: true} might not work with  certain other attributes set? My program is a daemon running as root, and sets Uid/Gid to another non-root user; it also uses github.com/kr/pty, the Start() method of which also sets some other attributes, .Setctty and .Setsid. I tried going through the golang stdlib startProcess() code and related bits, but don't fully understand how all of these optional flags interact.

Thanks,
-Russ

Kurtis Rader

unread,
Aug 8, 2019, 12:20:49 AM8/8/19
to Russtopia, golang-nuts
You need to tell us the OS you are using as well as the Go version. Beyond that you should be able to provide a minimal reproduction program for an issue of this sort.

Beyond the above, please note that in general you can't achieve what you're trying to do. The `setpgid()` syscall that the feature you are trying to use maps to can fail for several reasons. See `man setpgid`. Also, the error message you mention is typically associated with errno value EPERM. Depending on your OS there will be one or more reasons for that error.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAN4yCu-wxW6tfEcryOmkJUU6J3oVX6R3pHeOhpJFKsuReU%2BPhg%40mail.gmail.com.


--
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank
Reply all
Reply to author
Forward
0 new messages