G'day Stackoverflowers,
I'm the author of Perl's autodie pragma, which changes Perl's built-ins to throw exceptions on failure. It's similar to Fatal, but with lexical scope, an extensible exception model, more intelligent return checking, and much, much nicer error messages. It will be replacing the Fatal module in future releases of...
In short, how do you unit test an error condition such as EINTR on a system call.
One particular example I'm working on, which could be a case all by itself, is whether it's necessary to call fclose again when it returns EOF with (errno==EINTR). The behavior depends on the implementation of fclose:
// Given an open FILE *fp
while (fclo...
i am creating a system. What i want to know is if a msg is unsupported what should it do? should i throw saying unsupported msg? should i return 0 or -1? or should i set an errno (base->errno_). Some messages i wouldnt care if there was an error (such as setBorderColour). Others i would (addText or perhaps save if i create a save cmd).
...
If you are writing a multi-threaded application that uses system/library calls that make use of errno to indicate the error type, is there a safe way to use errno? If not, is there some other way to indicate the type of error that occurred rather than just that an error has occurred?
...
When calling execl(...) I get an errno=2. What does it mean ? How can I know the meaning of this errno ?
...
I am stuck with a fairly complex Python module that does not return useful error codes (it actually fails disturbingly silently). However, the underlying C library it calls sets errno.
Normally errno comes in over OSError attributes, but since I don't have an exception, I can't get at it.
Using ctypes, libc.errno doesn't work because e...
I'm porting some C++ code from UNIX to Windows which detects the occurrence of the EDQUOT error, which indicates that there was an unsuccessful attempt to exceed the current user's disk quota. Visual Studio's <errno.h> doesn't have an EDQUOT, although I know that Windows has disk quota functionality. Visual Studio's <errno.h> does have a...
In the book "The C Programming Language" it says:
"Many of the functions in the library set status indicators when error or end of file occur. These
indicators may be set and tested explicitly. In addition, the integer expression errno (declared
in <errno.h>) may contain an error number that gives further information about the mo...
C has perror and errno, which print and store the last error encountered. This is convenient when doing file io as I do not have to fstat() every file that fails as an argument to fopen() to present the user with a reason why the call failed.
I was wondering what is the proper way to grab errno when gracefully handling the IOError excep...
I am trying to create a table in MySQL with two foreign keys, which reference the primary keys in 2 other tables, but I am getting an errno: 150 error and it will not create the table.
Here is the SQL for all 3 tables:
CREATE TABLE role_groups (
`role_group_id` int(11) NOT NULL `AUTO_INCREMENT`,
`name` varchar(20),
`description` ...
I'm compiling code using gcc that comes from Visual C++ 2008. The code is using errno_t, but in some versions of gcc headers including <errno.h> doesn't define the type. How do I detect if the type is defined? Is there a define that signals that the type was defined? In the case it isn't defined I'd like to provide the typedef to let the...
Is there any function in UNIX to the convert errno to its corresponding string for e.g. EIDRM to "EIDRM". Its very annoying to debug to check for errors with these integer errnos.
...
I'm working with Rad Hat 8.0, trying to make changes to the kernel, and I'm at the compilation stage.
I have a header in include/linux where I define wrapper functions, and they use errno. I included errno.h using
#include <errno.h>.
When I try to compile, it tells me "errno.h no such file or directory". When I try
#include <linux/er...
Can anyone give me the right direction for this, as I am not able to find the declaration of EPERM in either pthread.h or errno.h (on openSUSE Linux). I found this in asm-generic/errno-base.h but is this the right one? Why its not in errno.h? Thanks
...
Does anyone know what this httperf error means? Is this having a negative effect on my tests?
httperf: connection failed with unexpected error 105
...
Another simple example:
if (wpa_s->mlme.ssid_len == 0)
return -EINVAL;
Why the unary minus? Is this (usually) done for functions that return >0 on success and <(=)0 on failure, or is there some other reason?
...
I'm looking to detect loops in symbolic links in a C program:
$ ln -s self self
$ ln -s a b
$ ln -s b a
Here's what I've got so far:
#include <sys/stat.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
int
main(int argc, char *argv[])
{
struct stat buffer;
int status;
if (argc != 2) {
...
I'm developing a dedicated game server on a linux machine, in C/C++ (mixed). I have the following snippet of code:
int sockfd=socket(AI_INET, SOCK_DGRAM, 0);
if(sockfd==-1)
{
int err=errno;
fprintf(stderr,"%s",strerror(err));
exit(1);
}
My problem here, is that socket is returning -1 (implying a failure) and the error stri...
Is there a command-line tool that will take a symbolic errno such as EINVAL and print the corresponding string, Invalid argument?
I would like to avoid having to find that EINVAL is value 22 on my system and then using$ perror 22.
Ideally I could write something like
$ errorcommand EINVAL
Invalid argument
$
...
Is it possible to access the "errno" variable in C# when P/Invoking? This is similar to Win32 GetLastError().
...