Beispiel #1
0
static void signal_force(struct thread *t, int num, int cause)
{
    /* If failed to deliver the signal that we're sending now, force it to run
     * with the default action. This will usually cause the process being killed.
     */
    if (num == cause) {
        t->owner->signal_act[num].sa_handler = SIG_DFT;
    }

    signal_send(t, num, NULL, TRUE);
}
Beispiel #2
0
static void producer(rtems_task_argument arg)
{
    test_context *ctx = (test_context *) arg;

    ctx->producer_processor = rtems_get_current_processor();

    rtems_test_assert(ctx->consumer_processor != ctx->producer_processor);

    wait_for_state(ctx, SIG_0_READY);
    signal_send(ctx, SIG_0_SENT);

    check_producer_processor(ctx);

    wait_for_state(ctx, SIG_1_READY);
    signal_send(ctx, SIG_1_SENT);

    check_producer_processor(ctx);

    rtems_task_suspend(RTEMS_SELF);
    rtems_test_assert(0);
}
Beispiel #3
0
static void timer_function(unsigned long par)
{ 
  ushort cpu_share; 

  if (unlikely(!pid_alive(check_task))) {
    del_timer(&check_timer);
    printk(KERN_INFO "sendsig: cannot find pid %i. Is the process still active? Timer removed\n", pid);
    return;
  }

  cpu_share = thread_group_cpu_share(check_task);

  if (cpu_share >= max_cpu_share) {
    count_check++;
    printk(KERN_INFO "sendsig: current cpu share over limit of %i (check #%i)\n", 
	   max_cpu_share, count_check);

/* the ratio is: if the process has a cpu share higher than
   max_cpu_share for more than max_checks * wait_timeout seconds, then
   we'll send the signal sig_to_send to it
 */    
    if (count_check >= max_checks) {
      /*
	sending the signal to the process
      */
      signal_send(check_task);
      /*
	remove the timer
      */ 
      del_timer(&check_timer);
      printk(KERN_INFO "sendsig: sent signal to process %i, timer removed\n", pid);
      return;
    } 
  } else {
    /*
      if the process is being good, let's reset its counter
    */
    count_check = 0;
  }  
  /*
    update the timer
  */
  mod_timer(&check_timer, jiffies + wait_timeout * HZ); 

  return;
}
Beispiel #4
0
errno_t
sc_kill(thread_t *p, syscall_result_t *r, kill_args_t *args)
{
    /* TODO:
     * 1) grupy procesow == -pid
     * 2) broadcast - pid == 0
     * 3) broadcast poza initem - pid == -1
     */

    proc_t *dest_proc = NULL;

    /* sprawdzamy sygnał */
    if ( args->sig < 0 || args->sig > _NSIG ) {
        r->result = -1;
        return EINVAL;
    }

    /* szukamy procesu, któremu mamy dostarczyć sygnał */
    dest_proc = proc_find(args->pid);

    if ( dest_proc == NULL && args->pid != 0 ) {
        r->result = -1;
        return ESRCH;
    }

    /* sprawdzamy czy możemy dostarczyć sygnał */
    /* ... */

    /* sprawdzamy komu dostarczamy sygnał */

    /* pojedynczy proces */
    if ( args->pid > 0 )
    {
        signal_send(dest_proc, args->sig);
        r->result = 0;
        return EOK;
    }

    /* Uzupelnic wg. TODO */
    r->result = -1;
    return -ENOSTR;
}
Beispiel #5
0
void signal_send_syscall(pid_t pid,int sig) {
  proc_t *proc = proc_find(pid);
  if (proc!=NULL) {
    if (proc->uid==proc_current->uid || proc->gid==proc_current->gid || proc_current->uid==PERM_ROOTUID || proc_current->gid==PERM_ROOTGID) signal_send(proc,sig);
  }
}
Beispiel #6
0
static void parse_args_post(int argc, char *argv[])
{
	optind = 1;

	for (;;)
	{
		char *gostr = "i:I:o:O:p:r:R:s:S:P:wadu:U" \
			      "L:g:hvVf:";

#ifdef HAVE_GETOPT_LONG
		struct option long_opts[] = {
			{"input", 1, 0, 'i'},
			{"secondary-input", 1, 0, 'I'},
			{"output", 1, 0, 'o'},
			{"secondary-output", 1, 0, 'O'},
			{"policy", 1, 0, 'p'},
			{"read-interval", 1, 0, 'r'},
			{"rate-interval", 1, 0, 'R'},
			{"sleep-interval", 1, 0, 's'},
			{"send-signal", 1, 0, 'S'},
			{"pidfile", 1, 0, 'P'},
			{"wait-for-signal", 0, 0, 'w'},
			{"show-all", 0, 0, 'a'},
			{"daemon", 0, 0, 'd'},
			{"uid", 1, 0, 'u'},
			{"use-si", 0, 0, 'U'},
			{"lifetime", 1, 0, 'L'},
			{"gid", 1, 0, 'g'},
			{0, 0, 0, 0},
		};
		int c = getopt_long(argc, argv, gostr, long_opts, NULL);
#else
		int c = getopt(argc, argv, gostr;
#endif

		if (c == -1)
			break;
		
		switch (c)
		{
			case 'i':
				input_set(optarg);
				break;

			case 'I':
				input_set_secondary(optarg);
				break;

			case 'o':
				output_set(optarg);
				break;

			case 'O':
				output_set_secondary(optarg);
				break;

			case 'p':
				cfg_setstr(cfg, "policy", optarg);
				break;

			case 'r':
				cfg_setfloat(cfg, "read_interval", strtod(optarg, NULL));
				break;

			case 'R':
				cfg_setfloat(cfg, "rate_interval", strtod(optarg, NULL));
				break;

			case 's':
				cfg_setint(cfg, "sleep_time", strtoul(optarg, NULL, 0));
				break;

			case 'S':
				signal_send(optarg);
				exit(0);

			case 'w':
				cfg_setint(cfg, "signal_driven", 1);
				break;

			case 'P':
				cfg_setstr(cfg, "pidfile", optarg);
				break;

			case 'a':
				cfg_setint(cfg, "show_all", 1);
				break;

			case 'd':
				cfg_setbool(cfg, "daemon", cfg_true);
				break;

			case 'u':
				cfg_setstr(cfg, "uid", optarg);
				break;

			case 'U':
				cfg_setbool(cfg, "use_si", cfg_true);
				break;

			case 'L':
				cfg_setint(cfg, "lifetime", strtoul(optarg, NULL, 0));
				break;

			case 'g':
				cfg_setstr(cfg, "gid", optarg);
				break;

			case 'f':
				/* Already handled in pre getopt loop */
				break;

			default:
				quit("Aborting...\n");
				break;

		}
	}
}