the return value of a process
the return value of a process
am 21.12.2007 09:07:58 von Rakesh UV
hi,
is there any way to find the exact meaning of message given
by a Unix command
for example
mv: cannot access hello.c
similarly is there any way to find the meaning of the
error number or message displayed
by compilers
Rakesh UV
Re: the return value of a process
am 21.12.2007 09:45:32 von Joachim Schmitz
"rakesh uv" schrieb im Newsbeitrag
news:74fa2b10-9b33-4493-9352-72608f866351@x29g2000prg.google groups.com...
> hi,
> is there any way to find the exact meaning of message given
> by a Unix command
> for example
> mv: cannot access hello.c
>
> similarly is there any way to find the meaning of the
> error number or message displayed
> by compilers
These should be in the documentation for the command in question.
If not: bad luck, you'd need to look at the source code instead.
Bye, Jojo
Re: the return value of a process
am 21.12.2007 10:45:11 von Stephane CHAZELAS
On Fri, 21 Dec 2007 00:07:58 -0800 (PST), rakesh uv wrote:
> hi,
> is there any way to find the exact meaning of message given
> by a Unix command
> for example
> mv: cannot access hello.c
[...]
Often error messages are converted from the error code returned
by a system call made by the command. It is not the case above
as the "standard error message" wouldn't have anything specific
like "hello.c" in it, but if the error message is not self
explanatory and if the documentation for you command is not
specific enough about the error messages, then you can sometimes
reverse engineer to understand what happens.
For instance, if you see:
$ ls /etc/motd/bar
/bin/ls: /etc/motd/bar: Not a directory
You can search what "Not a directory" is the message for. For
instance, if your shell is zsh, you can do:
$ zmodload zsh/system
$ {for e ($errnos) syserror -p$e: $e} |& grep -i 'not a dir'
ENOTDIR:Not a directory
That means that ls made a system call that returned with the
ENOTDIR error.
Now, if you think of what ls does, it retrieves file attributes,
so it must be doing a stat(2) system call.
Now, the stat(2) man page tels us:
ENOTDIR
A component of the path is not a directory.
That's a more useful message.
On Linux, you could do:
~$ strace -f ls /etc/motd/foo |& grep -i 'not a dir'
stat64("/etc/motd/foo", 0x805cd24) = -1 ENOTDIR (Not a directory)
write(2, ": Not a directory", 17: Not a directory) = 17
(the |& syntax is zsh/csh/tcsh specific)
That's a shorter way to now which error (ENOTDIR) to lookup in
which man page (stat64).
~$ man stat64 | sed '/ENOTDIR/,/^$/!d'
ENOTDIR
A component of the path is not a directory.
(other systems have commands equivalent to Linux' strace (truss,
tusc...)).
For compiler errors, look at the documentation for your compiler.
--
Stephane
Re: the return value of a process
am 21.12.2007 11:47:33 von Rakesh UV
On Dec 21, 2:45 pm, Stephane Chazelas
wrote:
> On Fri, 21 Dec 2007 00:07:58 -0800 (PST), rakesh uv wrote:
> > hi,
> > is there any way to find the exact meaning of message given
> > by a Unix command
> > for example
> > mv: cannot access hello.c
>
> [...]
>
> Often error messages are converted from the error code returned
> by a system call made by the command. It is not the case above
> as the "standard error message" wouldn't have anything specific
> like "hello.c" in it, but if the error message is not self
> explanatory and if the documentation for you command is not
> specific enough about the error messages, then you can sometimes
> reverse engineer to understand what happens.
>
> For instance, if you see:
>
> $ ls /etc/motd/bar
> /bin/ls: /etc/motd/bar: Not a directory
>
> You can search what "Not a directory" is the message for. For
> instance, if your shell is zsh, you can do:
>
> $ zmodload zsh/system
> $ {for e ($errnos) syserror -p$e: $e} |& grep -i 'not a dir'
> ENOTDIR:Not a directory
>
> That means that ls made a system call that returned with the
> ENOTDIR error.
>
> Now, if you think of what ls does, it retrieves file attributes,
> so it must be doing a stat(2) system call.
>
> Now, the stat(2) man page tels us:
> ENOTDIR
> A component of the path is not a directory.
>
> That's a more useful message.
>
> On Linux, you could do:
>
> ~$ strace -f ls /etc/motd/foo |& grep -i 'not a dir'
> stat64("/etc/motd/foo", 0x805cd24) = -1 ENOTDIR (Not a directory)
> write(2, ": Not a directory", 17: Not a directory) = 17
>
> (the |& syntax is zsh/csh/tcsh specific)
>
> That's a shorter way to now which error (ENOTDIR) to lookup in
> which man page (stat64).
>
> ~$ man stat64 | sed '/ENOTDIR/,/^$/!d'
> ENOTDIR
> A component of the path is not a directory.
>
> (other systems have commands equivalent to Linux' strace (truss,
> tusc...)).
>
> For compiler errors, look at the documentation for your compiler.
>
> --
> Stephane
Thanks stephane