mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2025-11-06 13:29:53 -05:00
fix: build warning
This commit is contained in:
parent
5b0faf2286
commit
1a174b1828
2 changed files with 8 additions and 3 deletions
|
|
@ -1353,7 +1353,12 @@ pid_t getparentprocess(pid_t p) {
|
|||
if (!(f = fopen(buf, "r")))
|
||||
return 0;
|
||||
|
||||
fscanf(f, "%*u %*s %*c %u", &v);
|
||||
// 检查fscanf返回值,确保成功读取了1个参数
|
||||
if (fscanf(f, "%*u %*s %*c %u", &v) != 1) {
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
|
||||
return (pid_t)v;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue