benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 4b8d8eb6-8d85-5496-a664-5df11b1a7a5d

Problem

Answer published by the source. Consult the official source to check your work against its answer.

complete prompt

import subprocess
import os
import signal
import time


def task_func(process_name: str) -> int:
    """
    Stops all running processes with a specific name.

    Parameters:
    process_name (str): The name of the processes to be stopped.

    Returns:
    int: The number of processes stopped. If no processes are found, returns 0.

    Requirements:
    - subprocess
    - os
    - signal
    - time

    Note:
    - The function sends a termination signal to the processes and waits for 1 second. 
      There is no guarantee that all processes will have terminated within this time.

    Example:
    >>> pids = task_func('test_name') # Dummy example, should return 0
    >>> pids
    0
    """

instruct prompt

Stops all running processes with a specific name.
Note that: The function sends a termination signal to the processes and waits for 1 second. There is no guarantee that all processes will have terminated within this time.
The function should output with:
    int: The number of processes stopped. If no processes are found, returns 0.
You should write self-contained code starting with:

Code

import subprocess
import os
import signal
import time
def task_func(process_name: str) -> int:

code prompt

Code

import subprocess
import os
import signal
import time
def task_func(process_name: str) -> int:

entry point

task_func

libs

  • subprocess
  • time
  • signal
  • os

Discussion

Discussion

No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

Source and history

Official source

initial import