How to check if a system call has successfully executed?
One way is to use command line $ dmesg
to look at kernel log. Is there any other way that we can do?
My first thinking is that, we could check the return value of a system call. However, we could not get the return value until the system call has been executed. Therefore, the second approach is shown below:
We could implement a new system call, in which it writes something into a buffer. Then, another system call reads the content of the buffer to check if the previous system call has written to the buffer. (Somehow like pthread_create
and pthread_join
)Hence, the implementation consists of 2 system calls in total.
What gets me stuck is that, where should we create the buffer? On stack? Or we make it a newly created file? And how to actually implement the two system calls?
Here is a sketch of my implementation written in pseudocode:
syscall_2(...){ if (syscall_1 executes) return 0; if (syscall_1 NOT executes) return -1;}syscall_1(){ do something; create a buffer; write something into buffer; return syscall_2(buffer); // checks what is in buffer}