Extracting permission of processes from the proc directory
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I am trying to write a program in C where I have to print out the pid of processes in the proc directory that have read and write permissions. I've opened the proc directory and read the processes inside - I am only looking at the numeric directories. I know that I will have to open each numeric directory and open its maps file. How can I extract the permissions of each processes? The code below contains my attempt:
sprintf(buf, "/proc/%d/maps", tgid->d_name);
file = fopen(buf, "r");
while (fgets(buf, sizeof(buf), file))
sscanf(buf, "%x-%x %4c %x %x:%x %lu", &from, &to, flags, &offset, &major, &minor, &ino);
fclose(file);
if (flags[0] == 'r' && flags[1] == 'w')
printf("%dn", tgid->d_name);
files permissions c proc
New contributor
add a comment |Â
up vote
0
down vote
favorite
I am trying to write a program in C where I have to print out the pid of processes in the proc directory that have read and write permissions. I've opened the proc directory and read the processes inside - I am only looking at the numeric directories. I know that I will have to open each numeric directory and open its maps file. How can I extract the permissions of each processes? The code below contains my attempt:
sprintf(buf, "/proc/%d/maps", tgid->d_name);
file = fopen(buf, "r");
while (fgets(buf, sizeof(buf), file))
sscanf(buf, "%x-%x %4c %x %x:%x %lu", &from, &to, flags, &offset, &major, &minor, &ino);
fclose(file);
if (flags[0] == 'r' && flags[1] == 'w')
printf("%dn", tgid->d_name);
files permissions c proc
New contributor
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am trying to write a program in C where I have to print out the pid of processes in the proc directory that have read and write permissions. I've opened the proc directory and read the processes inside - I am only looking at the numeric directories. I know that I will have to open each numeric directory and open its maps file. How can I extract the permissions of each processes? The code below contains my attempt:
sprintf(buf, "/proc/%d/maps", tgid->d_name);
file = fopen(buf, "r");
while (fgets(buf, sizeof(buf), file))
sscanf(buf, "%x-%x %4c %x %x:%x %lu", &from, &to, flags, &offset, &major, &minor, &ino);
fclose(file);
if (flags[0] == 'r' && flags[1] == 'w')
printf("%dn", tgid->d_name);
files permissions c proc
New contributor
I am trying to write a program in C where I have to print out the pid of processes in the proc directory that have read and write permissions. I've opened the proc directory and read the processes inside - I am only looking at the numeric directories. I know that I will have to open each numeric directory and open its maps file. How can I extract the permissions of each processes? The code below contains my attempt:
sprintf(buf, "/proc/%d/maps", tgid->d_name);
file = fopen(buf, "r");
while (fgets(buf, sizeof(buf), file))
sscanf(buf, "%x-%x %4c %x %x:%x %lu", &from, &to, flags, &offset, &major, &minor, &ino);
fclose(file);
if (flags[0] == 'r' && flags[1] == 'w')
printf("%dn", tgid->d_name);
files permissions c proc
files permissions c proc
New contributor
New contributor
edited 1 min ago
New contributor
asked 7 mins ago
user9042207
1
1
New contributor
New contributor
add a comment |Â
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
user9042207 is a new contributor. Be nice, and check out our Code of Conduct.
user9042207 is a new contributor. Be nice, and check out our Code of Conduct.
user9042207 is a new contributor. Be nice, and check out our Code of Conduct.
user9042207 is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f479809%2fextracting-permission-of-processes-from-the-proc-directory%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password