errno

Difference between Linux errno 23 and Linux errno 24

China☆狼群 提交于 2019-11-29 09:49:50
What is the difference between these 2 linux errors in errno.h ? 23 and 24 I tried 2 different sites but can't understand difference between the two. [EMFILE] Too many open files. [ENFILE] Too many files open in system. # define ENFILE 23 /* File table overflow */ # define EMFILE 24 /* Too many open files */ Also, I am getting errno 24 and socket call failing at 974th time. ( AF_INET UDP datagram socket) When I did a cat /proc/sys/fs/file-max I am seeing a value of 334076 ulimit -n showing 1024 Any idea what can be done to increase limit? For 1) Both error codes are about the situation with

waf--nginx,drizzle

谁说我不能喝 提交于 2019-11-29 03:35:32
一、概述: 1.研究目标:nginx中使用lua脚本,及nginx直接访问mysql,redis 2.需要安装的内容: openresty,mysql,redis 3.OpenResty (也称为 ngx_openresty)是一个全功能的 Web 应用服务器。它打包了标准的 Nginx 核心,很多的常用的第三方模块,以及它们的大多数依赖项。 http://openresty.org/cn/index.html 二、安装说明 0.环境准备 $yum install -y gcc gcc-c++ readline-devel pcre-devel openssl-devel tcl perl 1、安装drizzle http://wiki.nginx.org/HttpDrizzleModule cd /usr/local/src/ wget http://openresty.org/download/drizzle7-2011.07.21.tar.gz tar xzvf drizzle-2011.07.21.tar.gz cd drizzle-2011.07.21/ ./configure --without-server make libdrizzle-1.0 make install-libdrizzle-1.0 export LD_LIBRARY_PATH=/usr/local

How to convert errno in UNIX to corresponding string?

这一生的挚爱 提交于 2019-11-29 02:49:23
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. strerror() should do it. http://linux.die.net/man/3/strerror FYI, so that you can find these things more easily, yourself: If you type man errno (or whatever function you're investigating), and look at the very bottom of the man page, you'll see a list of related functions. If you man each of those (taking a guess about which one(s) to do first based on their names) you'll often find the answer to similar questions.

How to check the value of errno?

↘锁芯ラ 提交于 2019-11-29 02:35:48
I am using a system call and in case it fails, I need to do different things for different errnos. I need to write code that looks something like this: int res; res = systemCall(); if (res == -1) { if (errno == ENOMSG) { doSomething(); } else { doSomethingElse(); } } perror doesn't help, because it only prints the value. As for strerro - if it is what I need, I am not suer how to use it, because here it says that the actual string is not the same as the error. Quote from the man page: "(For example, if errnum is EINVAL, the returned description will be "Invalid argument")". I am using Linux.

php错误处理异常处理控制函数

自闭症网瘾萝莉.ら 提交于 2019-11-29 02:11:26
在实际开发中,错误及异常捕捉仅仅靠try{}catch()是远远不够的。 try { / /在这里主动抛出异常,(在这里说一下,php正常开发中最好不要主动抛出异常)   throw new Exception( 'Nicht aufgefangene Exception' ); } catch (Exception $e ) { var_dump( $e ); } 所以引用以下几中函数。 error_reporting(E_ALL);设置异常错误显示等级0为禁止错误 //禁用错误报告 error_reporting (0); //报告运行时错误 error_reporting (E_ERROR | E_WARNING | E_PARSE); //报告所有错误 error_reporting (E_ALL); //除去提醒处理 error_reporting (E_ALL~E_NOTICE); set_exception_handler 当出现异常try catch未捕捉到的时候就会触发一个参数是一个执行的自定义错误处理函数、可以是数组第一个值是那个类,第二个值是类里面的什么方法 register_shutdown_function 当php脚本执行即将关闭时执行的函数、脚本执行完或者出错如果再次之前设置过这个函数就会触发参数一个函数名用来处理、可以是系统内置也可以是自定义的

POSIX共享内存

只愿长相守 提交于 2019-11-29 01:59:12
前言 几种进程间的通信方式:管道,FIFO,消息队列,他们的共同特点就是通过内核来进行通信(假设POSIX消息队列也是在内核中实现的,因为POSIX标准并没有限定它的实现方式)。向管道,FIFO,消息队列写入数据需要把数据从进程复制到内核,从这些IPC读取数据的时候又需要把数据从内核复制到进程。所以这种IPC方式往往需要2次在进程和内核之间进行数据的复制,即进程间的通信必须借助内核来传递。如下图所示: 共享内存也是一种IPC,它是目前可用IPC中最快的,它是使用方式是将同一个内存区映射到共享它的不同进程的地址空间中,这样这些进程间的通信就不再需要通过内核,只需对该共享的内存区域进程操作就可以了,和其他IPC不同的是,共享内存的使用 需要用户自己进行同步操作 。下图是共享内存区IPC的通信: mmap系列函数简介 mmap函数主要的功能就是将文件或设备映射到调用进程的地址空间中,当使用mmap映射文件到进程后,就可以直接操作这段虚拟地址进行文件的读写等操作,不必再调用read,write等系统调用。在很大程度上提高了系统的效率和代码的简洁性。 使用mmap函数的主要目的是: 对普通文件提供内存映射I/O,可以提供无亲缘进程间的通信; 提供匿名内存映射,以供亲缘进程间进行通信。 对shm_open创建的POSIX共享内存区对象进程内存映射,以供无亲缘进程间进行通信。

Which systems define EAGAIN and EWOULDBLOCK as different values?

旧城冷巷雨未停 提交于 2019-11-28 22:22:05
问题 Just curious. Which systems providing both EAGAIN and EWOULDBLOCK #define them as different values? 回答1: There were some... http://www.gnu.org/s/hello/manual/libc/Error-Codes.html Portability Note: In many older Unix systems, this condition was indicated by EWOULDBLOCK, which was a distinct error code different from EAGAIN. To make your program portable, you should check for both codes and treat them the same. http://lists.parisc-linux.org/hypermail/parisc-linux/9895.html On some SysV systems

出错处理

社会主义新天地 提交于 2019-11-28 21:54:14
出错处理 文章目录 出错处理 1 出错处理选项 2 C语言机制 2.1 assert宏 2.2 使用预编译 2.3 标准库函数 3 使用系统日志 3.1 openlog函数 3.2 syslog函数 1 出错处理选项 代码段对出错处理有几种选择: 不做处理,这种方法不可取。 检测错误并向用户提供有关信息。 最好的一种出错处理选择是由Linux编程环境通过系统日志记录错误信息,这样可以永久地记录错误信息。 2 C语言机制 2.1 assert宏 宏assert的作用是如果它测试的条件返回错误(0),则终止程序执行。它先计算表达式expression,若其值为假,则先向stderr打印出错信息,然后调用函数abort来终止程序运行。 # include <assert.h> void assert ( int expression ) ; 2.2 使用预编译 2.3 标准库函数 # include <stdlib.h> void abort ( void ) ; void exit ( int status ) ; void atexit ( void ( * fun ) ( void ) ) ; # include <stdio.h> void perror ( const char * s ) ; # include <string.h> char * strerror ( int

Should I set errno?

好久不见. 提交于 2019-11-28 21:03:31
I'm writing a module which exports an interface similar to send and recv . Since those functions are supposed to return respectively the number of sent and received bytes, I cannot do proper error management as I would do normally (i.e. using enumeratives and returning mnemonic values). In a situation like this should I set errno as the standard library does? If so, since errno is thread specific, is there a particular way of writing on it, or can I simply assign a value to it? Edit: experimenting it I noticed that setting errno by assignment is working. Still: is this safe and portable for