2015-08-19から1日間の記事一覧

いつかまとめる予定③

psコマンドでUSER情報が8文字になるのはどうもこれが原因みたい。。。 ただなんでuidが8文字を超える場合は、UIDで表示するのかはわからない。 printf( "%8s %5d %5d %s %s %s %s", do_user(), P_pid, P_ppid, do_cpu(0), do_stime(), P_tty_text, do_time(P…

いつかまとめる予定②

さっきに続き とりあえずpsコマンドのソース minimal.c #ifdef __linux__/* return 1 if it works, or 0 for failure */static int stat2proc(int pid) { char buf[800]; /* about 40 fields, 64-bit decimal is about 20 chars */ int num; int fd; char* t…

いつかまとめる予定

メモ書き まずはソースコード #include <sys/stat.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <pwd.h> #define BUF 256 int main(void){ int p; char buf[800]; int rfp = 0; struct stat sb; struct passwd *k; rfp = open("/proc/2583/stat",O_RDONLY); printf("%d\n",rfp); fsta</pwd.h></fcntl.h></sys/stat.h></sys/types.h></sys/stat.h>…