Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

606 B
Raw Blame
import { expect } from 'vitest'
import { CommandExitError } from '../../../src/index.js'

import { sandboxTest } from '../../setup.js'

sandboxTest('kill process', async ({ sandbox }) => {
  const cmd = await sandbox.commands.run('sleep 10', { background: true })
  const pid = cmd.pid

  await sandbox.commands.kill(pid)

  await expect(sandbox.commands.run(`kill -0 ${pid}`)).rejects.toThrowError(
    CommandExitError
  )
})

sandboxTest('kill non-existing process', async ({ sandbox }) => {
  const nonExistingPid = 999999

  await expect(sandbox.commands.kill(nonExistingPid)).resolves.toBe(false)
})