Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

here is my test_code: enter image description here

enter image description here

And,when i run it,it prompt: enter image description here

Anyone can show me why?thx

share|improve this question

closed as off topic by Mat, sr_, Kevin, Michael Mrozek Feb 7 '12 at 16:29

Questions on Unix & Linux Stack Exchange are expected to relate to Unix or Linux within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

Don't know if it's related but, the header file errno.h should be included as this: include <errno.h> if it's located in /usr/include and not include </usr/include/errno.h>. – user13742 Feb 7 '12 at 8:25
This isn't really on topic here, it's a programming question. And it would be shot down on Stack Overflow. Please paste your (relevant) code as text, never as images. Same for your output. (Now your problem is: don't call perror if no error has happened. Check the return values of your system calls.) – Mat Feb 7 '12 at 8:25
what use do screenshots have here? Why don't you just paste the text? Looks much cleaner... Plus, people can help you better without having to type all in again... – glglgl Feb 7 '12 at 9:23
Also, according to the man page, getuid() always succeeds. – Ansgar Esztermann Feb 7 '12 at 9:42
thx,i got that.because i am running a primitive linux,crux,in the vmware,it is not easy to copy the prompt out.But,anyway,i will type it first next time – kaiwii ho Feb 8 '12 at 1:00

You are printing random error messages since igetuid() did not (and can not) fail. You only use perror() after a system call fails, and only once.

share|improve this answer
Emphasis on after – Kevin Feb 7 '12 at 15:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.