Question

I have a program called trickle that gives a warning and in its source code there is:

if (stat(sockname, &sb) == -1 &&
    (errno == EACCES || errno == ENOENT))
    warn("Could not reach trickled, working independently");

But the message I've got is:

trickle: Could not reach trickled, working independently: No such file or directory

Where does this No such file or directory come from?

Was it helpful?

Solution

I think that when you get a error value that is stocked in errno, the function warn can use it as a precision.

In this particular case I bet it's the ENOENT for Error NO ENTry that is in errno.

From man warn(3):

The err(), verr(), warn(), and vwarn() functions append an error message obtained from strerror(3) based on the global variable errno, preceded by another colon and space unless the fmt argument is NULL.

OTHER TIPS

That message is coming from the second part of your if (..) comparison.

The code has executed a stat() system call, on sockname. However, stat() returned ENOENT, which translates to "No such file or directory"

You need to find out how sockname is constructed to see whether it should have been valid.

The error is coming from the stat function and is being reported as part of the warn function. In more detail, from the warn documentation:

The Fn err and Fn warn family of functions display a formatted error message on the standard error output. In all cases, the last component of the program name, a colon character, and a space are output. If the Fa fmt argument is not NULL, the printf(3) -like formatted error message is output. The output is terminated by a newline character.

The Fn err , Fn verr , Fn warn , and Fn vwarn functions append an error message obtained from strerror(3) based on a code or the global variable errno preceded by another colon and space unless the Fa fmt argument is NULL enter code here

So the "No such file or directory" is coming from the stat operation because it can't find sockname and is being passed to the warn function via a code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top