Skip to content

runtime, cgo: cgo call to setgid hangs on GNU/Linux #3871

Closed
@ianlancetaylor

Description

@ianlancetaylor
This program hangs on GNU/Linux.

package main

/*
#include <sys/types.h>
#include <unistd.h>
*/
import "C"

import "fmt"

func main() {
    i, errno := C.setgid(1)
    fmt.Println(i, errno)
}

The problem is that when a threaded program calls setgid, the pthreads library sends a
SIGSETXID signal to each thread, and waits for the thread to acknowledge it.  The Go
runtime overrides the default signal handler with a Go-specific one.  Since the
os/signal package is not imported, the Go-specific signal handler simply ignores
SIGSETXID.  This means that the acknowledgement is never sent, and the program hangs.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions