update main #1

Merged
Sinipelto merged 240 commits from Bananymous/banan-os:main into main 2023-11-20 13:20:51 +02:00
1 changed files with 8 additions and 4 deletions
Showing only changes of commit a0fbf18d3b - Show all commits

View File

@ -1,5 +1,6 @@
#include <ctype.h> #include <ctype.h>
#include <dirent.h> #include <dirent.h>
#include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -30,8 +31,6 @@ int main()
if (!is_only_digits(proc_ent->d_name)) if (!is_only_digits(proc_ent->d_name))
continue; continue;
printf("process: ");
{ {
strcpy(path_buffer, proc_ent->d_name); strcpy(path_buffer, proc_ent->d_name);
strcat(path_buffer, "/cmdline"); strcat(path_buffer, "/cmdline");
@ -39,10 +38,13 @@ int main()
int fd = openat(dirfd(proc), path_buffer, O_RDONLY); int fd = openat(dirfd(proc), path_buffer, O_RDONLY);
if (fd == -1) if (fd == -1)
{ {
if (errno != EACCES)
perror("openat"); perror("openat");
continue; continue;
} }
printf("process: ");
while (ssize_t nread = read(fd, path_buffer, sizeof(path_buffer) - 1)) while (ssize_t nread = read(fd, path_buffer, sizeof(path_buffer) - 1))
{ {
if (nread < 0) if (nread < 0)
@ -61,10 +63,12 @@ int main()
written += printf("%s ", path_buffer + written); written += printf("%s ", path_buffer + written);
} }
printf("\n");
close(fd); close(fd);
} }
printf("\n pid: %s\n", proc_ent->d_name); printf(" pid: %s\n", proc_ent->d_name);
{ {
strcpy(path_buffer, proc_ent->d_name); strcpy(path_buffer, proc_ent->d_name);