#!/usr/bin/env python3
import sys
import time
import ctypes
import ctypes.util

# Get the desired process name from command line argument
process_name = sys.argv[1] if len(sys.argv) > 1 else 'killable_process'

# Set process name using prctl (Linux-specific)
# This sets the "comm" field which appears in ps output
try:
    libc = ctypes.CDLL(ctypes.util.find_library('c'))
    PR_SET_NAME = 15
    # Set the process name (limited to 16 characters including null terminator)
    name_bytes = process_name[:15].encode('utf-8')
    libc.prctl(PR_SET_NAME, name_bytes, 0, 0, 0)
except (OSError, AttributeError, Exception):
    # If prctl fails, continue anyway - the process will still run
    pass

# Also try to modify argv[0] so it appears in command line
try:
    sys.argv[0] = process_name
except:
    pass

# Run indefinitely
while True:
    time.sleep(3600)
