Hello. Interested in the next question. How to correctly get 4 fields in the / proc / self / stat file (4 fields is the pid of the process parent). in man proc it is written that the first three parameters are% d% s% c (if you use the scanf function). Our fourth is% d. But if you use spaces, brackets, other valid characters in the file name, in the simplest case, .out scanf (% * d% * s% * c% d)
cat / proc / 31707 / stat has the following output
31707 (kworker / u64: 1) S 2 0 0 0 -1 69247072 0 0 0 0 80 0 0 20 0 1 0 128062368 0 0 4294967295 0 0 0 0 0 0 0 2147483647 0 0 0 0 17 0 0 0 324 0 0 0 0 0 0 0 0 0
Therefore, the question arises how to correctly read the pid of the parent of a given process (not ours). As far as I know api there are none.
int ppid, n = fscanf(in, "%*d %*s %*s %d", &ppid);quite suitable (actually, you wrote it). And what is the question then? - avpprogram) S 45no one interferes - Mikefscanf()- avp