MCPcopy Create free account
hub / github.com/Simple-XX/SimpleKernel / test_sigkill

Function test_sigkill

tests/system_test/signal_test.cpp:96–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94}
95
96void test_sigkill(void* /*arg*/) {
97 klog::Info("=== Signal: SIGKILL Test ===");
98 bool passed = true;
99
100 auto& tm = TaskManagerSingleton::instance();
101 auto* self = tm.GetCurrentTask();
102
103 auto child = kstd::make_unique<TaskControlBlock>("SigkillTarget", 10,
104 sigkill_target, nullptr);
105 child->aux->parent_pid = self->pid;
106 auto* child_raw = child.get();
107 tm.AddTask(std::move(child));
108 Pid child_pid = child_raw->pid;
109
110 // Give the child time to start
111 (void)sys_sleep(100);
112
113 // Send SIGKILL
114 int ret = sys_kill(static_cast<int>(child_pid), signal_number::kSigKill);
115 if (ret != 0) {
116 klog::Err("test_sigkill: sys_kill returned {}", ret);
117 passed = false;
118 }
119
120 // Wait for the child
121 int status = 0;
122 auto wait_result = tm.Wait(child_pid, &status, false, false);
123 if (!wait_result.has_value() || wait_result.value() != child_pid) {
124 klog::Err("test_sigkill: Wait failed");
125 passed = false;
126 } else if (status != 128 + signal_number::kSigKill) {
127 klog::Err("test_sigkill: exit code {} (expected {})", status,
128 128 + signal_number::kSigKill);
129 passed = false;
130 }
131
132 if (!passed) {
133 g_tests_failed++;
134 }
135 g_tests_completed++;
136 klog::Info("Signal SIGKILL Test: {}", passed ? "PASSED" : "FAILED");
137 sys_exit(passed ? 0 : 1);
138}
139
140// ---------------------------------------------------------------------------
141// test_sigaction_ignore

Callers

nothing calls this directly

Calls 8

InfoFunction · 0.85
sys_sleepFunction · 0.85
sys_killFunction · 0.85
ErrFunction · 0.85
sys_exitFunction · 0.85
GetCurrentTaskMethod · 0.80
AddTaskMethod · 0.80
WaitMethod · 0.80

Tested by

no test coverage detected