"""
self.pakfire.execute(["/command", "check-open-file-descriptors"])
+ # Signals
+
+ def test_send_signal_DEFAULT(self):
+ """
+ Sends a stupid signal which doesn't do anything
+ """
+ self.pakfire.execute(["/command", "send-signal", "0"])
+
+ def test_send_signal_KILL(self):
+ """
+ Test the process killing itself
+ """
+ self.pakfire.execute(["/command", "send-signal", "9"])
+
+ def test_send_signal_TERM(self):
+ """
+ Test the process terminating itself
+ """
+ self.pakfire.execute(["/command", "send-signal", "15"])
+
# This is an interactive test which cannot be performed automatically
#def test_shell(self):
# self.pakfire.execute(["/bin/bash", "-i"])
return 0;
}
+static int send_signal(int argc, char* argv[]) {
+ int r;
+
+ if (argc < 1) {
+ fprintf(stderr, "No signal given\n");
+ return EXIT_FAILURE;
+ }
+
+ // Fetch our own PID
+ pid_t pid = getpid();
+
+ // Parse signal from command line
+ int signum = strtoul(argv[0], NULL, 10);
+
+ printf("Sending signal %d to ourselves (PID %d)\n", signum, pid);
+
+ r = kill(pid, signum);
+ if (r < 0) {
+ fprintf(stderr, "Error sending signal: %m\n");
+ return EXIT_FAILURE;
+ }
+
+ return EXIT_SUCCESS;
+}
+
int main(int argc, char* argv[]) {
if (argc < 2) {
fprintf(stderr, "No command given\n");
else if (strcmp(command, "print-pid") == 0)
callback = print_pid;
+ // Send signal
+ else if (strcmp(command, "send-signal") == 0)
+ callback = send_signal;
+
// Exit if no callback has been set
if (!callback) {
fprintf(stderr, "Unknown command: %s\n", command);