580 return (parse_ids(&g_psexp.ps_ctids, arg, 10, c, getctid()));
581 }
582
583 static void
584 print_usage(FILE *stream)
585 {
586 if (g_flags & F_KILL)
587 (void) fprintf(stream, gettext(PKILL_USAGE), g_pname);
588 else
589 (void) fprintf(stream, gettext(PGREP_USAGE), g_pname);
590 }
591
592 int
593 main(int argc, char *argv[])
594 {
595 void (*funcp)(psinfo_t *);
596
597 const char *optstr;
598 optdesc_t *optd;
599 int nmatches, c;
600
601 DIR *dirp;
602
603 (void) setlocale(LC_ALL, "");
604 (void) textdomain(TEXT_DOMAIN);
605
606 UU_EXIT_FATAL = E_ERROR;
607
608 g_pname = uu_setpname(argv[0]);
609 g_pid = getpid();
610
611 psexp_create(&g_psexp);
612
613 if (strcmp(g_pname, "pkill") == 0) {
614
615 if (argc > 1 && argv[1][0] == '-' &&
616 str2sig(&argv[1][1], &g_signal) == 0) {
617 argv[1] = argv[0];
618 argv++;
619 argc--;
620 }
621
622 optstr = PKILL_OPTS;
623 g_flags |= F_KILL;
624 } else
625 optstr = PGREP_OPTS;
626
627 opterr = 0;
628
629 while (optind < argc) {
630 while ((c = getopt(argc, argv, optstr)) != (int)EOF) {
631
632 if (c == ':' || c == '?' ||
633 g_optdtab[c - 'A'].o_opts == 0) {
634 if (c == ':') {
635 uu_warn(
636 gettext("missing argument -- %c\n"),
637 optopt);
638 } else if (optopt != '?') {
639 uu_warn(
640 gettext("illegal option -- %c\n"),
641 optopt);
642 }
643
644 print_usage(stderr);
645 return (E_USAGE);
646 }
647
648 optd = &g_optdtab[c - 'A'];
|
580 return (parse_ids(&g_psexp.ps_ctids, arg, 10, c, getctid()));
581 }
582
583 static void
584 print_usage(FILE *stream)
585 {
586 if (g_flags & F_KILL)
587 (void) fprintf(stream, gettext(PKILL_USAGE), g_pname);
588 else
589 (void) fprintf(stream, gettext(PGREP_USAGE), g_pname);
590 }
591
592 int
593 main(int argc, char *argv[])
594 {
595 void (*funcp)(psinfo_t *);
596
597 const char *optstr;
598 optdesc_t *optd;
599 int nmatches, c;
600 const char *zroot;
601 char buf[PATH_MAX];
602
603 DIR *dirp;
604
605 (void) setlocale(LC_ALL, "");
606 (void) textdomain(TEXT_DOMAIN);
607
608 UU_EXIT_FATAL = E_ERROR;
609
610 g_pname = uu_setpname(argv[0]);
611 g_pid = getpid();
612
613 psexp_create(&g_psexp);
614
615 if (strcmp(g_pname, "pkill") == 0) {
616
617 if (argc > 1 && argv[1][0] == '-' &&
618 str2sig(&argv[1][1], &g_signal) == 0) {
619 argv[1] = argv[0];
620 argv++;
621 argc--;
622 }
623
624 optstr = PKILL_OPTS;
625 g_flags |= F_KILL;
626 } else
627 optstr = PGREP_OPTS;
628
629 opterr = 0;
630
631 zroot = zone_get_nroot();
632 if (zroot != NULL) {
633 (void) snprintf(buf, sizeof (buf), "%s/%s", zroot, g_procdir);
634 g_procdir = buf;
635 }
636
637 while (optind < argc) {
638 while ((c = getopt(argc, argv, optstr)) != (int)EOF) {
639
640 if (c == ':' || c == '?' ||
641 g_optdtab[c - 'A'].o_opts == 0) {
642 if (c == ':') {
643 uu_warn(
644 gettext("missing argument -- %c\n"),
645 optopt);
646 } else if (optopt != '?') {
647 uu_warn(
648 gettext("illegal option -- %c\n"),
649 optopt);
650 }
651
652 print_usage(stderr);
653 return (E_USAGE);
654 }
655
656 optd = &g_optdtab[c - 'A'];
|