Esempio n. 1
0
int parse_command_line(int argc, char **argv, struct kill_list *klp)
{
   int i, kli;
   char *p;

   if (argc <= 1)
     {
       tell_usage();
       return(BAIL_OUT);
     }

   if (strcmp(argv[1], "0") == 0 || strcmp(argv[1], "-1") == 0)
     {
       printf("0 and -1 flags are not suported in OS/2 version\n");
       tell_usage();
       return(BAIL_OUT);
     }

   i = 1;
   if (*argv[i] == '-')         /* if a signal was specified */
     {
       if (strcmp(argv[i], "-l") == 0)
         {
            showsigs();
            return(BAIL_OUT);
         }
       if (edit_signal(argv[i], klp) == BAIL_OUT)
         return(BAIL_OUT);
       else
         if (++i == argc)       /* signal specified, but no pid */
           {
              tell_usage();
              return(BAIL_OUT);
           }
     }
   else
     klp->sigval = SIG_KILL;           /* default signal to send */

   for (kli = 0; i < argc && kli < MAXPID; i++)
     {
       for (p = argv[i]; *p; p++)
         if (!isdigit(*p))
           {
              printf("kill:  bad PID - %s\n", argv[i]);
              return(BAIL_OUT);
           }
       klp->pid[kli] = atoi(argv[i]);
       if (klp->pid[kli] == 0)
         printf("kill:  %s is not a valid PID\n", argv[i]);
       klp->pid[++kli] = 0;
     }
   if (kli == MAXPID)
     {
       printf("kill: too many PIDs requested.\n");
       return(BAIL_OUT);
     }

   return(OK);
}
Esempio n. 2
0
void			command_get(t_env *env, t_cmd *cmd)
{
	t_char		*list;
	t_cur		cur;

	edit_ini(&cur, env, cmd, &list);
	edit_line_display(list, &cur, cmd, env);
	while (!cmd->cmd_end)
	{
		env->key[0] = 0;
		read(0, env->key, 10);
		if (cmd->sig)
			if (edit_signal(&cur, env, cmd, &list))
				continue ;
		edit_update(env, &cur, cmd);
		if (!edit_key(env->key, cmd, &cur, &list))
			list = edit_char_add(list, env->key[0], &cur, cmd);
		if (list && cur.x > 0)
			list->mirror = 0;
		edit_line_display(list, &cur, cmd, env);
	}
	command_set(&cur, env, cmd, &list);
}