MCPcopy Create free account
hub / github.com/F-Stack/f-stack / db_kill

Function db_kill

freebsd/ddb/db_command.c:669–716  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

667}
668
669static void
670db_kill(db_expr_t dummy1, bool dummy2, db_expr_t dummy3, char *dummy4)
671{
672 db_expr_t old_radix, pid, sig;
673 struct proc *p;
674
675#define DB_ERROR(f) do { db_printf f; db_flush_lex(); goto out; } while (0)
676
677 /*
678 * PIDs and signal numbers are typically represented in base
679 * 10, so make that the default here. It can, of course, be
680 * overridden by specifying a prefix.
681 */
682 old_radix = db_radix;
683 db_radix = 10;
684 /* Retrieve arguments. */
685 if (!db_expression(&sig))
686 DB_ERROR(("Missing signal number\n"));
687 if (!db_expression(&pid))
688 DB_ERROR(("Missing process ID\n"));
689 db_skip_to_eol();
690 if (!_SIG_VALID(sig))
691 DB_ERROR(("Signal number out of range\n"));
692
693 /*
694 * Find the process in question. allproc_lock is not needed
695 * since we're in DDB.
696 */
697 /* sx_slock(&allproc_lock); */
698 FOREACH_PROC_IN_SYSTEM(p)
699 if (p->p_pid == pid)
700 break;
701 /* sx_sunlock(&allproc_lock); */
702 if (p == NULL)
703 DB_ERROR(("Can't find process with pid %ld\n", (long) pid));
704
705 /* If it's already locked, bail; otherwise, do the deed. */
706 if (PROC_TRYLOCK(p) == 0)
707 DB_ERROR(("Can't lock process with pid %ld\n", (long) pid));
708 else {
709 pksignal(p, sig, NULL);
710 PROC_UNLOCK(p);
711 }
712
713out:
714 db_radix = old_radix;
715#undef DB_ERROR
716}
717
718/*
719 * Reboot. In case there is an additional argument, take it as delay in

Callers

nothing calls this directly

Calls 3

db_expressionFunction · 0.85
db_skip_to_eolFunction · 0.85
pksignalFunction · 0.85

Tested by

no test coverage detected