Exemple #1
0
/*
 * clean_up_processes: In effect, we want to tell all of our sub processes
 * that we're going away.  We cant be 100% sure that theyre all dead by
 * the time this function returns, but we can be 100% sure that they will
 * be killed off next time they come up to run.  This is the only thing that
 * can be guaranteed, and is in fact all we really need to know.
 */
void 		clean_up_processes (void)
{
	if (process_list_size)
	{
		say("Closing all left over exec's");
		kill_all_processes(SIGTERM);
		sleep(2);
		get_child_exit(-1);
		kill_all_processes(SIGKILL);
	}
}
Exemple #2
0
/* forced shutdown, used for wineserver -k */
void shutdown_master_socket(void)
{
    kill_all_processes();
    shutdown_stage = 2;
    if (shutdown_timeout)
    {
        remove_timeout_user( shutdown_timeout );
        shutdown_timeout = NULL;
    }
    close_master_socket( 2 * -TICKS_PER_SEC );  /* for SIGKILL timeouts */
}
Exemple #3
0
static void
signal_handler (int sig)
{
	kill (login_pid, -9);
	sleep (1);
	kill_all_processes ();
	if (sig == SIGUSR1)
	{
		reboot (RB_AUTOBOOT);
	}
	else
	{
		reboot (RB_POWER_OFF);
	}
}
Exemple #4
0
void signal_handler_main(int sig)
{
	switch(sig) 
	{
		case SIGHUP:
			printf("\nhangup signal catched");
			break;
		case SIGTERM:
		case SIGKILL:
		case SIGINT:
			printf("\nterminate signal catched");
			kill_all_processes(main_p->pgid);
			exit(0);
			break;
	}
}
Exemple #5
0
/* callback for server shutdown */
static void server_shutdown_timeout( void *arg )
{
    shutdown_timeout = NULL;
    if (!running_processes)
    {
        close_master_socket( 0 );
        return;
    }
    switch(++shutdown_stage)
    {
    case 1:  /* signal system processes to exit */
        if (debug_level) fprintf( stderr, "wineserver: shutting down\n" );
        if (shutdown_event) set_event( shutdown_event );
        shutdown_timeout = add_timeout_user( 2 * -TICKS_PER_SEC, server_shutdown_timeout, NULL );
        close_master_socket( 4 * -TICKS_PER_SEC );
        break;
    case 2:  /* now forcibly kill all processes (but still wait for SIGKILL timeouts) */
        kill_all_processes();
        break;
    }
}
Exemple #6
0
int main()
{
	if(read_config_files(&cf)== -1)
	{
		printf("\nError in reading config files");
		exit(0);
	}
//---declare variable of program----//
	
	int listen_sd, accept_sd;
	struct sockaddr_in addr;  
	int i;
 
//--------------load action record from file-----------------------//
	int numberofac;
	char *filename = cf.action_record;
	ActionRecord *ac;
	ac = ReadOutputFile(filename,&numberofac);
	if(ac == NULL)
	{
		printf("\nCannot read action record file");
		return 0;

	}
	//sort the array with the action's starting time
	SortActionArray(ac,numberofac);
	printf("\nnumber of action record:%d",numberofac);

	
//-------------load action mapping file------------------------//
	char *action_mapping_file = cf.action_mapping;
	action_mapping *ap ;
	int numberofap =0;
	ap = read_action_mapping_file(action_mapping_file,&numberofap);
	if(ap == NULL)
	{
		printf("\nCannot read action mapping file");
		return 0;

	}
	action_mapping *temp;
	temp = ap;
	while(temp!=NULL)
	{
		print_action_mapping(temp);
		temp=temp->next;
	}

		
	
	

//-------------------------------load setting file ---------------//

	char *setting_file = cf.setting_file;
	id_ip *ID_IP;
	int numberofnode;
	ID_IP =  read_setting_file(setting_file,&numberofnode);
	if(ID_IP == NULL)
	{
		printf("\nCannot read setting file");
		return 0;
	}
	printf("\nnumber of node in setting file:%d\n",numberofnode);
	

//------------INIT main process to control child processes----------------//

	main_process_init();

//--------------INIT server for listening the time value from QOMET-------//
    /* If an argument was specified, use it to */
    /* control the number of incoming connections */
     listen_sd = InitTCPServer(SERVER_PORT);
	if(listen_sd < 1)
	{
		fprintf(stderr,"Server cannot init");
		return 0;
	}

//--------------------------main loop----------------------//
	
	do_actions(listen_sd,ac,numberofac,ap,ID_IP);

//------------------------close program--------------------//
    /* Close the listen socket */
    close(listen_sd);
	//kill all child processes//
	kill_all_processes(main_p->pgid);
	//wait for close main process//
	wait_to_close();
    return 0;
//--------------close program in bad cases-----------------------//
bad_main:
	printf("\nclose do action program\n");
	close(listen_sd);
	close(accept_sd);
	kill_all_processes(main_p->pgid);
	exit(-1);
}