/proc/[pid]/cmdline file size
问题 i'm trying to get the filesize of the cmdline file in proc/[pid]. For example porc/1/cmdline. The file is not empty, it contains "/sbin/init". But i get file_size = 0. int main(int argc, char **argv) { int file_size; FILE *file_cmd; file_cmd = fopen("/proc/1/cmdline", "r"); if(file_cmd == NULL) { perror("proc/1/cmdline"); exit(1); }else { if(fseek(file_cmd, 0L, SEEK_END)!=0) { perror("proc/1/cmdline"); exit(1); } file_size = ftell(file_cmd); } printf("fs: %d\n",file_size); fclose(file_cmd); }