Ejemplo n.º 1
0
static void
win32_check_children_running(void)
{
    HANDLE hProc[NUM_CHILD_PROCS];
    DWORD  dwResult;

    hProc[0] = (HANDLE)pid_ui;
    hProc[1] = (HANDLE)pid_engine;

    dwResult = WaitForMultipleObjects(NUM_CHILD_PROCS, hProc, FALSE, 0);
    if (dwResult >= WAIT_OBJECT_0 && dwResult < WAIT_OBJECT_0 + NUM_CHILD_PROCS) {
        debug_msg("Process %lu is no longer running\n",
                  (uint32_t)hProc[dwResult - WAIT_OBJECT_0]);
        kill_process(pid_ui);
        kill_process(pid_engine);
        exit(-1);
        return;
    }

    if (dwResult >= WAIT_ABANDONED_0 && dwResult < WAIT_ABANDONED_0 + NUM_CHILD_PROCS) {
        debug_msg("Process %lu wait abandoned\n",
                  (uint32_t)hProc[dwResult - WAIT_ABANDONED_0]);
        return; /* Nothing to do, process quit already */
    }

    if (dwResult == WAIT_FAILED) {
        debug_msg("Wait failed\n");
        return;
    }

    assert(dwResult == WAIT_TIMEOUT);
    return;
}
Ejemplo n.º 2
0
int main()
{

    printf("press a to send hydro\npress b to send solar\npress up to send flag\n\n");

    while(!a_button() && !b_button() && !up_button());
    if(a_button())
    {
        while(a_button());
        init_captain_planet_with_our_powers_combined();
        kill_process(TIMER_WATCHDOG_ID);
        printf("result of charge: %d\n",charge(HYDRO));
    }
    else if(b_button())
    {
        while(b_button());
        init_captain_planet_with_our_powers_combined();
        kill_process(TIMER_WATCHDOG_ID);
        printf("result of charge: %d\n",charge(SOLAR));
    }
    else if(up_button())
    {
        while(up_button());
        init_captain_planet_with_our_powers_combined();
        kill_process(TIMER_WATCHDOG_ID);
        printf("result of charge: %d\n",charge(FLAG));
    }

    kill_process(TIMER_PROCESS_ID);
    serializer_disconnect();
}
Ejemplo n.º 3
0
/* Signal Handlers */
static void
sigint_handler(int signal)
{
    UNUSED(signal);
    debug_msg("Caught signal %d\n", signal);
    kill_process(pid_ui);
    kill_process(pid_engine);
    exit(-1);
}
Ejemplo n.º 4
0
/* send an fd to a client */
int send_client_fd( struct process *process, int fd, obj_handle_t handle )
{
    struct iovec vec;
    struct msghdr msghdr;
    int ret;

#ifdef HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS
    msghdr.msg_accrightslen = sizeof(fd);
    msghdr.msg_accrights = (void *)&fd;
#else  /* HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS */
    char cmsg_buffer[256];
    struct cmsghdr *cmsg;
    msghdr.msg_control    = cmsg_buffer;
    msghdr.msg_controllen = sizeof(cmsg_buffer);
    msghdr.msg_flags      = 0;
    cmsg = CMSG_FIRSTHDR( &msghdr );
    cmsg->cmsg_len   = CMSG_LEN( sizeof(fd) );
    cmsg->cmsg_level = SOL_SOCKET;
    cmsg->cmsg_type  = SCM_RIGHTS;
    *(int *)CMSG_DATA(cmsg) = fd;
    msghdr.msg_controllen = cmsg->cmsg_len;
#endif  /* HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS */

    msghdr.msg_name    = NULL;
    msghdr.msg_namelen = 0;
    msghdr.msg_iov     = &vec;
    msghdr.msg_iovlen  = 1;

    vec.iov_base = (void *)&handle;
    vec.iov_len  = sizeof(handle);

    if (debug_level)
        fprintf( stderr, "%04x: *fd* %04x -> %d\n", current ? current->id : process->id, handle, fd );

    ret = sendmsg( get_unix_fd( process->msg_fd ), &msghdr, 0 );

    if (ret == sizeof(handle)) return 0;

    if (ret >= 0)
    {
        fprintf( stderr, "Protocol error: process %04x: partial sendmsg %d\n", process->id, ret );
        kill_process( process, 1 );
    }
    else if (errno == EPIPE)
    {
        kill_process( process, 0 );
    }
    else
    {
        fprintf( stderr, "Protocol error: process %04x: ", process->id );
        perror( "sendmsg" );
        kill_process( process, 1 );
    }
    return -1;
}
Ejemplo n.º 5
0
static void mbus_err_handler(int seqnum, int reason)
{
    /* Something has gone wrong with the mbus transmission. At this time */
    /* we don't try to recover, just kill off the media engine and user  */
    /* interface processes and exit.                                     */

    if (should_exit == FALSE) {
        char msg[64];
        sprintf(msg, "Could not send mbus message (%d:%d)\n", seqnum, reason);
        fatal_error("RAT v" RAT_VERSION, msg);
        kill_process(pid_ui);
        kill_process(pid_engine);
        abort();
    }
}
Ejemplo n.º 6
0
void handle_signal(int sig){
    switch (sig){
    case SIGUSR1:
    case SIGUSR2:
      syslog(LOG_DEBUG, "recieved SIGUSR %d", sig);
      if (kill_server() < 0) { 
	syslog(LOG_CRIT,"SIGHANDLER: unable to kill server");
	break;
      }
      if (kill_index() < 0) { 
	syslog(LOG_CRIT,"SIGHANDLER: unable to kill index");
	break;
      }
      if (init_index() < 0) {
	syslog(LOG_CRIT,"SIGHANDLER: unable to init index - index STILL down");
	break;
      }
      if (init_server(main_ctx) < 0) {
	syslog(LOG_CRIT,"SIGHANDLER, unable to init server - index up but unknown by main server");
	break;
      }
      break;
    case SIGHUP:
    case SIGTERM:
	syslog(LOG_DEBUG, "recieved SIGTERM %d", sig);
	if (kill_server() < 0) syslog(LOG_CRIT,"SIGHANDLER: unable to kill server");
	if (kill_index() < 0) syslog(LOG_CRIT,"SIGHANDLER: unable to kill index");
	kill_process();
	/* should this be called ??? */
        /* if called, must close sockets in threads */
        /* before calling                           */
	/* zmq_term(main_ctx); */
	exit(0);
    }
}
Ejemplo n.º 7
0
void FindLine()
{
  int iCur;
  int iProc;
  int wInit;

  DebugStop("Find Line Start");

  Lookdown();
  iCur = iSight;

  wInit = wLD;
  iProc = start_process(Move(1000,1000));

  while (iSight == iCur && !fBlocked && !fStalled && !fBall)
    {
    printf("FindLine: %d\n", iSight);
    defer();
    Lookdown();
    }
  printf("I:%d, B:%d S:%d\n", iSight, fBlocked, fStalled);
  kill_process(iProc);
  SetMotors(0,0);
  if (fBlocked || fStalled)
    Unbind();
}
Ejemplo n.º 8
0
void Placebo()
{
	int i;
	
  ir_transmit_off();
  fAssertEnable = YesNo("Debug");
  kill_process(ipMotor);
  if (YesNo("Start Light"))
    start_machine(START_LIGHT_PORT);
  ipMotor = start_process(MotorDriver());
  CompeteInit(0);
  Orient();

	FindLine();

  while (1)
  	{
  	Hard(90);
  	Move(-100, -100);
  	Move(80, 80);
  	Hard(90);
  	Move(-200, -200);
  	msleep(1000L);
  	Chop(3);
  	Move(50, 50);
  	Wheelie();
  	}
}
Ejemplo n.º 9
0
int main()
{
    int a = 10;
    int b = 20;
    swap(&a,&b);
    char choice;
    pid=0;
    free_block = init_free_block(mem_size); //初始化空闲区
    for(;;)
    {
        display_menu();	//显示菜单
        fflush(stdin);
        choice=getchar();	//获取用户输入
        switch(choice)
        {
            case '1': set_mem_size(); break; 	//设置内存大小
            case '2': set_algorithm();flag=1; break;	//设置分配算法
            case '3': new_process(); flag=1; break;	//创建新进程
            case '4': kill_process();flag=1; break;	//删除进程
            case '5': display_mem_usage(); flag=1; break;	//显示内存使用
            case '0': do_exit(); exit(0);		//释放链表并退出
            default: break;
        }
        getchar();
    }
}
Ejemplo n.º 10
0
static void		check_lives_process(t_core *c)
{
	t_list		*ptr_w;
	t_list		*ptr_p;
	t_warrior	*warrior;
	t_proc		*process;

	ptr_w = c->warriors;
	while (ptr_w)
	{
		warrior = (t_warrior *)ptr_w->content;
		ptr_p = warrior->procs;
		while (ptr_p)
		{
			process = (t_proc *)ptr_p->content;
			ptr_p = ptr_p->next;
			if ((c->ncycles - process->last_live) > c->cycle_to_die
			|| !process->live)
				kill_process(c, warrior, process);
			else
				process->live = 0;
		}
		ptr_w = ptr_w->next;
	}
}
Ejemplo n.º 11
0
extern "C" int __declspec(dllexport) release_all()
{
	int n=0;
	for(int j=0;j<tb_cnt;j++)
		if(ID[j]!=-1) n+=kill_process(ID[j]);
	tb_cnt=0;
	return n;
};
Ejemplo n.º 12
0
bool cprocess_tree::kill_process(_In_ const wchar_t* process_name)
{
	_ASSERTE(NULL != process_name);
	if (NULL == process_name) return false;

	DWORD pid = find_process(process_name);
	return kill_process(pid);
}
Ejemplo n.º 13
0
static void
kill_process_helper(ProcData *procdata, int sig)
{
    if (procdata->config.show_kill_warning)
        procdialog_create_kill_dialog (procdata, sig);
    else
        kill_process (procdata, sig);
}
Ejemplo n.º 14
0
void
cb_kill_sigcont(GtkAction *action, gpointer data)
{
    ProcData * const procdata = static_cast<ProcData*>(data);

    /* no confirmation */
    kill_process (procdata, SIGCONT);
}
Ejemplo n.º 15
0
void pc_handle_signal(int sig __attribute__ ((unused)))
{
	int i;

	for(i = 0; i < num_processes; i++)
		if(process[i].state)
			kill_process(&process[i]);
	exit(0);
}
Ejemplo n.º 16
0
static void
kill_process_with_confirmation (GsmApplication *app, int signal) {
    gboolean kill_dialog = app->settings->get_boolean(GSM_SETTING_SHOW_KILL_DIALOG);

    if (kill_dialog)
        procdialog_create_kill_dialog (app, signal);
    else
        kill_process (app, signal);
}
Ejemplo n.º 17
0
void handle_signal(int sig){

    switch (sig){
    case SIGHUP:
    case SIGTERM:
	syslog(LOG_INFO, "recieved signal, %d", sig);
	kill_server();
	kill_process();
	exit(0);
    }
}
Ejemplo n.º 18
0
/* send an fd to a client */
int send_client_fd( struct process *process, int fd, obj_handle_t handle )
{
    int ret;

    if (debug_level)
        fprintf( stderr, "%04x: *fd* %p -> %d\n",
                 current ? current->id : process->id, handle, fd );

#ifdef HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS
    msghdr.msg_accrightslen = sizeof(fd);
    msghdr.msg_accrights = (void *)&fd;
#else  /* HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS */
    msghdr.msg_control    = &cmsg;
    msghdr.msg_controllen = sizeof(cmsg.header) + sizeof(fd);
    cmsg.fd = fd;
#endif  /* HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS */

    myiovec.iov_base = (void *)&handle;
    myiovec.iov_len  = sizeof(handle);

    ret = sendmsg( get_unix_fd( process->msg_fd ), &msghdr, 0 );

    if (ret == sizeof(handle)) return 0;

    if (ret >= 0)
    {
        fprintf( stderr, "Protocol error: process %04x: partial sendmsg %d\n", process->id, ret );
        kill_process( process, NULL, 1 );
    }
    else if (errno == EPIPE)
    {
        kill_process( process, NULL, 0 );
    }
    else
    {
        fprintf( stderr, "Protocol error: process %04x: ", process->id );
        perror( "sendmsg" );
        kill_process( process, NULL, 1 );
    }
    return -1;
}
Ejemplo n.º 19
0
void handle_vm_fault_cb(int pid, seL4_CPtr cap, void* args, int err) {
    /* Reply */
    if (SOS_DEBUG) printf("handle_vm_fault_cb\n");
    if (err) {
        //this could happen. in this case the process needs to be killed 
        kill_process(pid, pid, cap);
        return;
    }

    send_seL4_reply(cap, pid, 0);
    if (SOS_DEBUG) printf("handle_vm_fault_cb ended\n");
}
Ejemplo n.º 20
0
void _shut_down_task()
{
	int i,j;
	msleep(_shut_down_delay);
	create_stop();
	ao();
	//disable_servos(); // delete this line if you want your servos to freeze but remain powered at the end
	Bb_Game_Over= 1;
	printf("Game over");
	i= 0;
	for (j= 256; j <= 1024; j+=256) {
		//        hog_processor();
		while (i < j) {
			kill_process(_shut_down_pid+(++i));
			kill_process(_shut_down_pid-i);
		}
		ao();
		disable_servos(); // delete this line if you want your servos to freeze but remain powered at the end
	}
	printf(".\n");
}
Ejemplo n.º 21
0
Archivo: botball.c Proyecto: CBCJVM/cbc
// run_for takes a function and runs it for a certain amount of time
// run_for will return within 1 second of your function exiting, if it
// exits before the specified time.
void run_for(float howLong, void (*funky))
{
       int pid=start_process(funky);
       while(howLong >= 1.0){
               if(!is_process_running(pid)) return;
               sleep(1.0);
               howLong=howLong-1.0;
       }
       sleep(howLong);
       kill_process(pid);
       return;
}
Ejemplo n.º 22
0
static void
kill_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data)
{
	struct KillArgs *kargs = static_cast<KillArgs*>(data);
	
	gtk_widget_destroy (GTK_WIDGET (dialog));

	if (id == GTK_RESPONSE_OK) 
		kill_process (kargs->procdata, kargs->signal);

	g_free (kargs);
}
Ejemplo n.º 23
0
static void
kill_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data)
{
    struct ProcActionArgs *kargs = static_cast<ProcActionArgs*>(data);

    gtk_widget_destroy (GTK_WIDGET (dialog));

    if (id == GTK_RESPONSE_OK)
        kill_process (kargs->app, kargs->arg_value);

    g_free (kargs);
}
Ejemplo n.º 24
0
int kill_child_and_collect(int pid)
{
	int status;

	status = kill_process(pid);
	if (status != -ESRCH)
		return status;

	if (collect_child(pid, &status, 0))
		return -ECHILD;

	return status;
}
Ejemplo n.º 25
0
void server_stop_process(process_s *process)
{
    int res;

    if(process->is_running)
    {
        process->is_running = 0;
        kill_process(process, &res);
        process->pid = 0;
        process->start_time = 0;
        process->restart_times = 0;
        syslog(LOG_INFO, "Stopping %s.",process->app_name);
    }
}
Ejemplo n.º 26
0
Archivo: main.c Proyecto: diegohdorta/C
int main(void)
{
	struct process_arguments x = { 0 };
	pid_t app_listener;
	pid_t web_listener;
	pid_t bank_listener;

	start_log_file();
	
	do {
		
		app_listener = create_process(communication_app, &x);
		web_listener = create_process(communication_web, &x);
		bank_listener = create_process(communication_bank, &x);

	} while (true);
	
	kill_process(app_listener);
	kill_process(web_listener);
	kill_process(bank_listener);	


	return EXIT_SUCCESS;
}
Ejemplo n.º 27
0
Archivo: exec.c Proyecto: srfrog/epic5
/*
 * This kills (sends a signal, *NOT* ``make it stop running'') all of the
 * currently running subprocesses with the given signal.  Presumably this
 * is because you want them to die.
 *
 * Remember that UNIX signals are asynchronous.  At best, you should assume
 * that they have an advisory effect.  You can tell a process that it should
 * die, but you cannot tell it *when* it will die -- that is up to the system.
 * That means that it is pointless to assume the condition of any of the 
 * kill()ed processes after the kill().  They may indeed be dead, or they may
 * be ``sleeping but runnable'', or they might even be waiting for a hardware
 * condition (such as a swap in).  You do not know when the process will
 * actually die.  It could be 15 ns, it could be 15 minutes, it could be
 * 15 years.  Its also useful to note that we, as the parent process, will not
 * recieve the SIGCHLD signal until after the child dies.  That means it is
 * pointless to try to reap any children processes here.  The main io()
 * loop handles reaping children (by calling get_child_exit()).
 */
static void 	kill_all_processes (int signo)
{
	int	i;
	int	tmp;

	tmp = window_display;
	window_display = 0;
	for (i = 0; i < process_list_size; i++)
	{
		if (process_list[i])
		{
			ignore_process(i);
			kill_process(i, signo);
		}
	}
	window_display = tmp;
}
Ejemplo n.º 28
0
static void
on_activate_send_signal (GSimpleAction *, GVariant *parameter, gpointer data)
{
    GsmApplication *app = (GsmApplication *) data;

    /* no confirmation */
    gint32 signal = g_variant_get_int32(parameter);
    switch (signal) {
        case SIGCONT:
            kill_process (app, signal);
            break;
        case SIGSTOP:
        case SIGTERM:
        case SIGKILL:
            kill_process_with_confirmation (app, signal);
            break;
    }
}
Ejemplo n.º 29
0
void handle_vm_fault(seL4_Word badge, int pid) {
    
    seL4_CPtr reply_cap;
    seL4_Word fault_vaddr = seL4_GetMR(1);
    if (SOS_DEBUG) printf("handle_vm_fault, %p\n", (void *) fault_vaddr);
    // Get the page of the fault address
    fault_vaddr &= PAGE_MASK;
    //dprintf(0, "Handling fault at: 0x%08x\n", fault_vaddr);
    reply_cap = cspace_save_reply_cap(cur_cspace);

    int err = map_if_valid(fault_vaddr, pid, handle_vm_fault_cb, NULL, reply_cap);
    if (err == GUARD_PAGE_FAULT || err == UNKNOWN_REGION || err == NULL_DEREF) {

        //kill the process as it has faulted invalid memory
        kill_process(pid, pid, reply_cap);
    }
    if (SOS_DEBUG) printf("handle_vm_fault finished\n");
}
Ejemplo n.º 30
0
void Compete()
{
  int i;

  ir_transmit_off();
  fAssertEnable = YesNo("Debug");
  kill_process(ipMotor);
  if (YesNo("Start Light"))
    start_machine(START_LIGHT_PORT);
  ipMotor = start_process(MotorDriver());
  CompeteInit(0);
  Orient();
  while (1)
    {
    FindLine();
    CollectBalls();
    /* BUG: We don't really know if we have a ball here */
    DumpBall();
    ReturnForMore();
    }
  printf("C1");
}