aruu

[MIRROR] Actual replacement for Busybox | suckless
git clone https://git.daat.foo/aruu.git
Log | Files | Refs | README | LICENSE

proc_posix.c (1522B)


      1 /* see LICENSE file for copyright and license details */
      2 #include "../proc.h"
      3 #include "../util.h"
      4 
      5 #include <errno.h>
      6 #include <stdlib.h>
      7 #include <string.h>
      8 
      9 /* a kernel with no backend yet: its process table is not read, and every
     10  * tool that wants it says why. proc_linux.c is the one that reads it */
     11 #if !defined(__linux__) || defined(ARUU_FORCE_POSIX)
     12 
     13 int
     14 parsecmdline(pid_t pid, char *buf, size_t siz)
     15 {
     16   (void)pid;
     17   (void)buf;
     18   (void)siz;
     19   errno = ENOTSUP;
     20   return -1;
     21 }
     22 
     23 int
     24 parsestat(pid_t pid, struct procstat *ps)
     25 {
     26   (void)pid;
     27   (void)ps;
     28   errno = ENOTSUP;
     29   return -1;
     30 }
     31 
     32 int
     33 parsestatus(pid_t pid, struct procstatus *pstatus)
     34 {
     35   (void)pid;
     36   (void)pstatus;
     37   errno = ENOTSUP;
     38   return -1;
     39 }
     40 
     41 int
     42 pidfile(const char *file)
     43 {
     44   char *end;
     45 
     46   errno = 0;
     47   strtol(file, &end, 10);
     48   return *end == '\0' && errno == 0;
     49 }
     50 
     51 int
     52 proc_each(proc_fn *fn, void *arg)
     53 {
     54   (void)fn;
     55   (void)arg;
     56   errno = ENOTSUP;
     57   return -1;
     58 }
     59 
     60 int
     61 proc_info(pid_t pid, struct procinfo *p)
     62 {
     63   (void)pid;
     64   memset(p, 0, sizeof *p);
     65   errno = ENOTSUP;
     66   return -1;
     67 }
     68 
     69 int
     70 proc_args(pid_t pid, char *buf, size_t n)
     71 {
     72   return parsecmdline(pid, buf, n);
     73 }
     74 
     75 int
     76 proc_cwd(pid_t pid, char *buf, size_t n)
     77 {
     78   (void)pid;
     79   (void)buf;
     80   (void)n;
     81   errno = ENOTSUP;
     82   return -1;
     83 }
     84 
     85 void
     86 proc_ttyname(unsigned major, unsigned minor, char *buf, size_t n)
     87 {
     88   (void)major;
     89   (void)minor;
     90   if (n)
     91     strlcpy(buf, "?", n);
     92 }
     93 
     94 ssize_t
     95 proc_selfexe(char *buf, size_t n)
     96 {
     97   (void)buf;
     98   (void)n;
     99   errno = ENOTSUP;
    100   return -1;
    101 }
    102 
    103 #endif