Skip to content

runtime: program can exit 0 after runtime.Goexit from main #7711

@snaury

Description

@snaury
This was originally reported here:

https://bugs.launchpad.net/gozk/+bug/1278930

But while investigating the issue I found that this has nothing to do with gokz and
happens if any C function is called during init(). Here's an example program that
demonstrates the issue:

package main

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

import (
    "fmt"
    "runtime"
)

func init() {
    C.sleep(0)
}

func main() {
    fmt.Println("Hello!")
    runtime.Goexit()
}

Instead of exiting after printing "Hello!" this program hangs up.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions