惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

MyScale Blog
MyScale Blog
爱范儿
爱范儿
The Register - Security
The Register - Security
小众软件
小众软件
D
DataBreaches.Net
雷峰网
雷峰网
S
Secure Thoughts
L
LINUX DO - 最新话题
M
MIT News - Artificial intelligence
Application and Cybersecurity Blog
Application and Cybersecurity Blog
罗磊的独立博客
F
Fortinet All Blogs
博客园 - 叶小钗
TaoSecurity Blog
TaoSecurity Blog
博客园 - Franky
aimingoo的专栏
aimingoo的专栏
S
SegmentFault 最新的问题
Hacker News: Ask HN
Hacker News: Ask HN
Help Net Security
Help Net Security
N
News and Events Feed by Topic
S
Security Affairs
The Last Watchdog
The Last Watchdog
Forbes - Security
Forbes - Security
S
Security @ Cisco Blogs
Latest news
Latest news
O
OpenAI News
N
Netflix TechBlog - Medium
云风的 BLOG
云风的 BLOG
Blog — PlanetScale
Blog — PlanetScale
Google Online Security Blog
Google Online Security Blog
S
Securelist
博客园 - 司徒正美
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
T
Threat Research - Cisco Blogs
C
CXSECURITY Database RSS Feed - CXSecurity.com
P
Palo Alto Networks Blog
T
The Blog of Author Tim Ferriss
Stack Overflow Blog
Stack Overflow Blog
I
InfoQ
阮一峰的网络日志
阮一峰的网络日志
AI
AI
SecWiki News
SecWiki News
G
GRAHAM CLULEY
Cloudbric
Cloudbric
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
L
LINUX DO - 热门话题
C
Cybersecurity and Infrastructure Security Agency CISA
B
Blog RSS Feed

博客园 - 风易微凉

AI笔记-快捷键2 AI笔记 快捷键1 AI笔记-钢笔PEN 我的2025 倒影中的你 后座有你 踏入破解行业 一个人、一场梦、一座空城、一生心疼 人间有味是清欢 安卓开发中遇到耗电量高的问题解决方案 no no no no 敢说不 逆向工程-反编译,嵌入 AlarmManager的使用 基于项目中遇到的技术问题,谈谈SharedPreferences的使用的注意问题 MongoDB数据库日志备份压缩脚本 mongodb数据库磁盘碎片整理。 mongodb库表信息监控脚本 mongodb mapreduce示例 mongodb表字段处理生成域名字段
根据当前进程号,获取进程下线程数目
风易微凉 · 2014-04-02 · via 博客园 - 风易微凉
 1 /*根据当前进程号,获取进程下线程数目*/
 2 int get_max_thread_count()
 3 {
 4     char filename[FILENAME_MAX];
 5     snprintf(filename, sizeof(filename)-1, "/proc/%u/stat", getpid());
 6 
 7     FILE* fp = fopen(filename, "r");
 8     if (NULL == fp) return -1;
 9     
10 
11     char line[LINE_MAX];
12     int filed_number = 38;
13     process_info_t process_info;
14     char* linep = fgets(line, sizeof(line)-1, fp);
15 
16     if (NULL == linep) return -1;
17     sscanf(line, "%d%s%s%d%d"
18                          "%d%d%d%u%lu"
19                          "%lu%lu%lu%lu%lu"
20                          "%ld%ld%ld%ld%ld"
21                          "%ld%lld%lu%ld%lu"
22                          "%lu%lu%lu%lu%lu"
23                          "%lu%lu%lu%lu%lu"
24                          "%lu%d%d"
25               /** 01 */ ,&process_info.pid
26               /** 02 */ , process_info.comm
27               /** 03 */ ,&process_info.state
28               /** 04 */ ,&process_info.ppid
29               /** 05 */ ,&process_info.pgrp
30               /** 06 */ ,&process_info.session
31               /** 07 */ ,&process_info.tty_nr
32               /** 08 */ ,&process_info.tpgid
33               /** 09 */ ,&process_info.flags
34               /** 10 */ ,&process_info.minflt
35               /** 11 */ ,&process_info.cminflt
36               /** 12 */ ,&process_info.majflt
37               /** 13 */ ,&process_info.cmajflt
38               /** 14 */ ,&process_info.utime
39               /** 15 */ ,&process_info.stime
40               /** 16 */ ,&process_info.cutime
41               /** 17 */ ,&process_info.cstime
42               /** 18 */ ,&process_info.priority
43               /** 19 */ ,&process_info.nice
44               /** 20 */ ,&process_info.num_threads
45               /** 21 */ ,&process_info.itrealvalue
46               /** 22 */ ,&process_info.starttime
47               /** 23 */ ,&process_info.vsize
48               /** 24 */ ,&process_info.rss
49               /** 25 */ ,&process_info.rlim
50               /** 26 */ ,&process_info.startcode
51               /** 27 */ ,&process_info.endcode
52               /** 28 */ ,&process_info.startstack
53               /** 29 */ ,&process_info.kstkesp
54               /** 30 */ ,&process_info.kstkeip
55               /** 31 */ ,&process_info.signal
56               /** 32 */ ,&process_info.blocked
57               /** 33 */ ,&process_info.sigignore
58               /** 34 */ ,&process_info.sigcatch
59               /** 35 */ ,&process_info.nswap
60               /** 36 */ ,&process_info.cnswap
61               /** 37 */ ,&process_info.exit_signal
62               /** 38 */ ,&process_info.processor);
63     
64     
65     fclose(fp);
66     return process_info.num_threads;
67 }