The following code returns -1, how can I know what’s wrong?
get a detailed error or something?
if (read(programFile, value, sizeof(FRAME)) == -1) {
return SYSTEM_CALL;
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You need to look into
errno, which is a variable set by system calls to indicate an error. You can use the convenience functionperrorto get a human-readable printout.It can return something like
No such file or directory. Either way its a good practice to use it.Check out
man errnoandman perrorfor more information.