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

推荐订阅源

S
Secure Thoughts
T
The Exploit Database - CXSecurity.com
C
CERT Recently Published Vulnerability Notes
P
Palo Alto Networks Blog
T
Threatpost
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
T
Tenable Blog
F
Full Disclosure
TaoSecurity Blog
TaoSecurity Blog
I
InfoQ
AI
AI
云风的 BLOG
云风的 BLOG
K
Kaspersky official blog
Microsoft Azure Blog
Microsoft Azure Blog
S
SegmentFault 最新的问题
Y
Y Combinator Blog
GbyAI
GbyAI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
P
Privacy International News Feed
aimingoo的专栏
aimingoo的专栏
罗磊的独立博客
酷 壳 – CoolShell
酷 壳 – CoolShell
I
Intezer
L
Lohrmann on Cybersecurity
博客园_首页
量子位
Blog — PlanetScale
Blog — PlanetScale
The Last Watchdog
The Last Watchdog
Cisco Talos Blog
Cisco Talos Blog
博客园 - 叶小钗
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Help Net Security
Help Net Security
Security Archives - TechRepublic
Security Archives - TechRepublic
Apple Machine Learning Research
Apple Machine Learning Research
W
WeLiveSecurity
N
News and Events Feed by Topic
S
Schneier on Security
T
Tor Project blog
MongoDB | Blog
MongoDB | Blog
博客园 - 三生石上(FineUI控件)
V
Visual Studio Blog
T
Threat Research - Cisco Blogs
H
Help Net Security
V
V2EX
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
S
Security @ Cisco Blogs
博客园 - Franky
有赞技术团队
有赞技术团队
Martin Fowler
Martin Fowler

博客园 - 风易微凉

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 }