file - negative return value in Open system call; C -
i have created file in /proc
named "test" (it created in kernel). file exists. when want open in user level returns negative.
int fd; if((fd=open("/proc/test","o_rdonly"))<0){ perror("open"); }
the error see open: file exists
. have seen this question not case.
you need parentheses in there (now fixed in question), , second argument open()
not string:
#include <fcntl.h> int fd; if ((fd = open("/proc/test", o_rdonly)) < 0) perror("open");
i'm not convinced idea create file of sort in /proc
file system. in fact, i'm bit surprised allowed to. if learning program root
, hope have backups.
Comments
Post a Comment