Skip to content

Can't kill process on Windows #1263

@Tobbe

Description

@Tobbe

I can't seem to figure out how to kill a process on Windows. What am I doing wrong?

    const ac = new AbortController()
    const { signal } = ac

    const jobsProcess = $({ signal })`yarn rw jobs work`.timeout(19600)

    jobsProcess.stdout.on('data', (data) => {
      console.log('jobsProcess stdout data', data.toString())
    })

    setTimeout(() => {
      console.log('Killing jobsProcess SIGINT')
      jobsProcess.kill('SIGINT')

      setTimeout(() => {
        console.log('Killing jobsProcess SIGTERM')
        jobsProcess.kill('SIGTERM')
      }, 100)

      setTimeout(() => {
        console.log('Killing jobsProcess SIGTERM')
        jobsProcess.kill('SIGTERM')
      }, 200)

      setTimeout(async () => {
        console.log('Killing jobsProcess SIGKILL')
        await jobsProcess.kill('SIGKILL')
        console.log('After killing jobsProcess with SIGKILL')
      }, 400)

      setTimeout(() => {
        console.log('Aborting jobsProcess')
        ac.abort('Should be done by now')
      }, 1000)
    }, 9600)

    const { stdout, stderr } = await jobsProcess
    
    console.log('Job finished')

I see all the console logs, except the last one ('Job finished'). The process just keeps running (and keeps spitting out "jobsProcess stdout data" from the .stdout.on handler)

It all works great locally on my Mac, and on Ubuntu on GitHub CI. But not on Windows on GitHub CI.

How do I kill the process on Windows?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions