KDK_GET_PROCESS_ALL_INFORMATION(3)
✨ KDK_GET_PROCESS_ALL_INFORMATION ✨
okay bestie, welcome to the Library Functions Manual section 💖 you're literally about to meet the function that scoops up every single process on your system at once. no cap.
🎀 NAME 🎀
kdk_get_process_all_information — 获取系统中所有进程的信息 (aka: grab the deets on every process in the system, all of them, the whole roster 💅)
🦋 SYNOPSIS 🦋
#include <libkyprocess.h>
extern char** kdk_get_process_all_information();
Link with -lkyrtinfo. (yes, that's the flag. don't forget it, she's important ✨)
🌸 Detailed Description 🌸
The main function of the interface is to obtain information about all processes in the system. that's it. that's the whole vibe. she's a gatherer, a collector, a main character who knows everyone 👑
💜 RETURN VALUE 💜
- On success — returns all process information of type
char**, ending with aNULLcharacter. Generated byallocand needs to be recycled bykdk_proc_freeall🫶 - On error — return
NULL.
bestie listen: that memory came fromalloc, so you have to hand it back withkdk_proc_freeall. don't just walk away from her, that's not the move 😭
🍓 EXAMPLES 🍓
here's the whole demo, verbatim, no edits, she's iconic:
#include "libkyprocess.h"
#include <stdio.h>
#include <stdlib.h>
int main()
{
char *run_time = kdk_get_process_running_time(841);
char *cpu_time = kdk_get_process_cpu_time(841);
char *cmd = kdk_get_process_command(841);
char *start_time = kdk_get_process_start_time(841);
printf("获取某一进程的CPU利用率:%0.1f0, kdk_get_process_cpu_usage_percent(841));
printf("获取某一进程的内存占用率:%0.1f0, kdk_get_process_mem_usage_percent(841));
printf("获取某一进程的进程状态:%s0, kdk_get_process_status(841));
printf("获取某一进程的进程端口号:%d0, kdk_get_process_port(841));
printf("获取某一进程的启动时间:%s0, start_time);
printf("获取某一进程的运行时间:%s0, run_time);
printf("获取某一进程的CPU时间:%s0, cpu_time);
printf("获取某一进程的Command:%s0, cmd);
printf("获取某一进程的属主:%s0, kdk_get_process_user(841));
free(run_time);
free(cpu_time);
free(cmd);
free(start_time);
char** pid = kdk_procname_get_process_infomation("systemd");
size_t index = 0;
while (pid[index])
{
printf("pid %s0, pid[index]);
index ++;
}
kdk_proc_freeall(pid);
char** info = kdk_get_process_all_information();
size_t count = 0;
while (info[count])
{
printf("No. %d %s0, count + 1, info[count]);
count ++;
}
kdk_proc_freeall(info);
char *name = kdk_get_process_name(1151571);
printf("name = %s0, name);
free(name);
int id = kdk_get_process_id("systemd");
printf("pid %d0, id);
return 0;
}
see how she loops while (info[count]) until she hits that NULL? that's the sentinel, bestie, that's how you know you're done 🌈 and then kdk_proc_freeall(info) — closure, periodt 💅
👑 CONFORMING TO 👑
These functions are as per the withdrawn POSIX.1e draft specification. (withdrawn, babe, it's giving vintage 🕰️)
The following functions are Linux extensions:
kdk_get_process_name()kdk_get_process_id()kdk_get_process_cpu_usage_percent()kdk_get_process_mem_usage_percent()kdk_get_process_status()kdk_get_process_port()kdk_get_process_start_time()kdk_get_process_running_time()kdk_get_process_cpu_time()kdk_get_process_command()kdk_get_process_user()kdk_procname_get_process_infomation()kdk_proc_freeall()
🔥 SEE ALSO 🔥
the whole friend group, go say hi 💖
kdk_get_process_name(3)kdk_get_process_id(3)kdk_get_process_cpu_usage_percent(3)kdk_get_process_mem_usage_percent(3)kdk_get_process_status(3)kdk_get_process_port()kdk_get_process_start_time(3)kdk_get_process_running_time(3)kdk_get_process_cpu_time(3)kdk_get_process_command(3)kdk_get_process_user(3)kdk_procname_get_process_infomation(3)kdk_proc_freeall(3)
and that's the page, bestie!! 🦋 this lil gem comes from the Linux Programmer's Manual, dated Mon Sep 18 2023 — she's a Libra-era classic, no cap. go forth and enumerate every process, you absolute icon 👑💅✨
📦 where this page comes from
- arch rolling: libkysdk-system 3.0.1.4-1 · LGPL-3.0-or-later AND LGPL-2.1-only OR LGPL-3.0-only AND LGPL-2.1-only WITH Qt-LGPL-exception-1.1 OR LGPL-3.0-only WITH Qt-LGPL-exception-1.1 AND MIT
- ubuntu resolute: libkysdk-system-dev 3.0.1.2-0ubuntu1 · LGPL-3.0-only
- ubuntu stonking: libkysdk-system-dev 3.0.1.3-0ubuntu1 · LGPL-3.0-or-later
- 💖 girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms