bun icon indicating copy to clipboard operation
bun copied to clipboard

process.kill(constants.signals.SIGINT) not working as expected

Open maxmcd opened this issue 2 years ago • 0 comments
trafficstars

What version of Bun is running?

0.5.6

What platform is your computer?

Linux 5.15.0-1015-aws x86_64 x86_64

What steps can reproduce the bug?

import { spawn } from "bun";
import  {constants} from "node:os";

const sleeper = spawn(["go", "run", "./foo"], {
    stdin: "inherit",
    stdout: "inherit",
});

setTimeout(() => {
    (async function() {
        console.log("hi", constants.signals.SIGINT)
        sleeper.kill(constants.signals.SIGINT)
        console.log(await sleeper.exited)
        console.log(sleeper.killed)
        console.log(sleeper.signalCode)
        console.log(sleeper.exitCode || 0)
    })()
}, 1000)

The SIGINT never makes it to the process. Some other signals do seem to make it to the process (SIGIL seems to work), and if I SIGINT bun itself the SIGINT will make it to the child process, but sending the signal in the code above seems to do nothing and the process hangs indefinitely.

Go code being run:

package main

import (
	"fmt"
	"os"
	"os/signal"
	"syscall"
	"time"
)

func main() {
	fmt.Println("Im up")
	sigs := make(chan os.Signal, 1)
	// listen for all signals
	signal.Notify(sigs)
	sig := <-sigs
	// if any signal fires, print it, sleep a second and then exit 0
	fmt.Printf("Got signal %q, shutting down...", sig)
	time.Sleep(time.Second)
}

What is the expected behavior?

The SIGINT should make it to the go program, which should exit and print a message that it has received the signal.

What do you see instead?

No signal reaches the Go program, the program continues to run.

Additional information

Bun is so nice.

maxmcd avatar Feb 17 '23 15:02 maxmcd