# The PID must be 1
self.assertEqual(message, "1")
- self.pakfire.execute(["/command", "pid"], logging_callback=checkpid)
+ self.pakfire.execute(["/command", "print-pid"], logging_callback=checkpid)
def test_nice(self):
self.pakfire.execute(["/command", "print-nice"], nice=5)
return 0;
}
-static int pid(int argc, char* argv[]) {
- pid_t pid = getpid();
- if (!pid)
- return 1;
+static int print_nice(int argc, char* argv[]) {
+ int nice = getpriority(PRIO_PROCESS, 0);
- // Print the PID
- printf("%d\n", pid);
+ // Print the nice level
+ printf("%d\n", nice);
return 0;
}
-static int print_nice(int argc, char* argv[]) {
- int nice = getpriority(PRIO_PROCESS, 0);
+static int print_pid(int argc, char* argv[]) {
+ pid_t pid = getpid();
+ if (!pid)
+ return 1;
- // Print the nice level
- printf("%d\n", nice);
+ // Print the PID
+ printf("%d\n", pid);
return 0;
}
else if (strcmp(command, "lines") == 0)
callback = lines;
- // Print PID
- else if (strcmp(command, "pid") == 0)
- callback = pid;
-
// Print nice level
else if (strcmp(command, "print-nice") == 0)
callback = print_nice;
+ // Print PID
+ else if (strcmp(command, "print-pid") == 0)
+ callback = print_pid;
+
// Exit if no callback has been set
if (!callback) {
fprintf(stderr, "Unknown command: %s\n", command);