import cffi import signal ffi = cffi.FFI() ffi.cdef(''' typedef void *pthread_t; int pthread_kill(pthread_t thread, int sig); pthread_t pthread_self(); ''') lib = ffi.dlopen(None) lib.pthread_kill(lib.pthread_self(), signal.SIGINT)