apue
#ifndef apue_h #define apue_h #define _POSIX_C_SOURCE 200809L #if defined(SOLARIS) /* Solaris 10 */ #define _XOPEN_SOURCE 600 #else #define _XOPEN_SOURCE 700 #endif #include <sys/types.h> /* some systems still require this */ #include <sys/stat.h> #include <sys/termios.h> /*for winsize */ #if defined(MACOS) || !defined(TIOCGWINSZ) #include <sys/ioctl.h> #endif #include <stdio.h> /* for convenience */ #include <stdlib.h> /* for convenience */ #include <stddef.h> /* for offsetof */ #include <string.h> /* for convenience */ #include <unistd.h> /* for convenience */ #include <signal.h> /* for SIG_ERR */ #define MAXLINE 4096 /* max line length */ /* Default file access permissions for new files. */ #define FILE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) /* Default permissions for new directories.*/ #define DIR_MODE (FILE_MODE | S_IXUSR | S_IXGRP | S_IXOTH) typedef void Sigfunc(int); /*for signal handlers */ #define min(a,b) ((a) < (b) ? (a) : (b)) #define max(a,b) ((a) > (b) ? (a) : (b)) /* Prototypes for our own functions. */ char *path_alloc(size_t *); long open_max(void); int set_cloexec(int); void clr_fl(int,int); void set_fl(int,int); void pr_exit(int); void pr_mask(const char *); Sigfunc *signal_intr(int,Sigfunc *); void daemonize(const char *); void sleep_us(unsigned int); ssize_t readn(int,void *,size_t); ssize_t writen(int,const void *,size_t); int fd_pipe(int *); int recv_fd(int,ssize_t (*func)(int,const void*,size_t)); int send_fd(int,int); int send_err(int,int,const char *); int serv_listen(const char *); int serv_accept(int,uid_t *); int cli_conn(const char *); int buf_args(char *,int (*func)(int,char **)); int tty_cbreak(int); int tty_raw(int); int tty_reset(int); void tty_atexit(void); struct termios *tty_termios(void); int ptym_open(char *,int); int ptys_open(char *); #ifdef TIOCGWINSZ pid_t pty_fork(int *,char *,int,const struct termios *,const struct winsize *); #endif int lock_reg(int,int,int,off_t,int,off_t); #define read_lock(fd,offset,whence,len) lock_reg((fd),F_SETLK,F_RDLCK,(offset),(whence),(len)) #define readw_lock(fd,offset,whence,len) lock_reg((fd),F_SETLKW,F_RDLCK,(offset),(whence),(len)) #define write_lock(fd,offset,whence,len) lock_reg((fd),F_SETLK,F_WRLCK,(offset),(whence),(len)) #define writew_lock(fd,offset,whence,len) lock_reg((fd),F_SETLKW,F_WRLCK,(offset),(whence),(len)) #define un_lock(fd,offset,whence,len) lock_reg((fd),F_SETLK,F_UNLCK,(offset),(whence),(len)) pid_t lock_test(int,int,off_t,int,off_t); #define is_read_lockable(fd,offset,whence,len) (lock_test((fd),F_RDLCK,(offset),(whence),(len)) == 0) #define is_write_lockable(fd,offset,whence,len) (lock_test((fd),F_WRLCK,(offset),(whence),(len)) == 0) void err_msg(const char *,...); void err_dump(const char *,...) __attribute__((noreturn)); void err_quit(const char *,...) __attribute__((noreturn)); void err_cont(int,const char *,...); void err_exit(int,const char *,...) __attribute__((noreturn)); void err_ret(const char *,...); void err_sys(const char *,...) __attribute__((noreturn)); void log_msg(const char *,...); void log_open(const char *,int ,int); void log_quit(const char *,...) __attribute__((noreturn)); void log_ret(const char *,...); void log_sys(const char *,...) __attribute__((noreturn)); void log_exit(int,const char *,...) __attribute__((noreturn)); void TELL_WAIT(void); void TELL_PARENT(pid_t); void TELL_CHILD(pid_t); void WAIT_PARENT(void); void WAIT_CHILD(void); #endif /* apue_h */
apue的更多相关文章
- [APUE]进程控制(上)
一.进程标识 进程ID 0是调度进程,常常被称为交换进程(swapper).该进程并不执行任何磁盘上的程序--它是内核的一部分,因此也被称为系统进程.进程ID 1是init进程,在自举(bootstr ...
- [APUE]UNIX进程的环境(下)
一.共享库 共享库使得可执行文件中不再需要包含常用的库函数,而只需在所有进程都可存取的存储区中保存这种库例程的一个副本.程序第一次执行的时候或第一次调用某个库函数的时候,用动态链接方法将程序与共享库函 ...
- [APUE]标准IO库(下)
一.标准IO的效率 对比以下四个程序的用户CPU.系统CPU与时钟时间对比 程序1:系统IO 程序2:标准IO getc版本 程序3:标准IO fgets版本 结果: [注:该表截取自APUE,上表中 ...
- APUE中fcntl.h的使用及O_SYNC在Mac与Ubuntu下的测试
此部分测试涉及到APUE V3中,第三章的图3-12到图3-14. 通过fcntl.h提供的功能,修改fd的文件属性,本处增加O_SYNC功能,并测试其效果. 本文涉及代码: tree ch3 ch3 ...
- APUE fig 1.10示例代码的完善--对提示符及输入回车的优化
APUE 第3版第15页的shell2.c示例程序,运行效果如下: gcc ol.shell.c -o origin_shell ./origin_shell % date 2015年12月13日 星 ...
- 关于apue.3e中apue.h的使用
关于apue.3e中apue.h的使用 近来要学一遍APUE第三版,并于此开博做为记录. 先下载源文件: # url: http://http//www.apuebook.com/code3e.htm ...
- APUE学习之多线程编程(三):线程属性、同步属性
一.线程属性 可以使用pthread_attr_t结构修改线程默认属性,并这些属性和创建的线程练习起来,可以使用pthread_att_init函数初始化pthread_attr_t结构,调 ...
- APUE学习之多线程编程(二):线程同步
为了保证临界资源的安全性和可靠性,线程不得不使用锁,同一时间只允许一个或几个线程访问变量.常用的锁有互斥量,读写锁,条件变量 一.互斥量 互斥量是用pthrea ...
- APUE学习之多线程编程(一):线程的创建和销毁
一.线程标识 和每个进程都有一个进程ID一样,每个线程也有一个线程ID,线程ID是以pthread_t数据类型来表示的,在Linux中,用无符号长整型表示pthread_t,Solaris ...
- APUE学习之出错处理
当UNIX函数发生错误时,通常会返回一个负值,而且整形变量errno通常被设置为具有特定信息的值. errno是全局变量,仅当函数出错才有被改变.对待errno,应注意两条规则 ...
随机推荐
- SharedPreferences的工具类,使用起来方便、快捷
SharedPreferences的工具类,使用起来方便.快捷:上代码:import android.content.Context;import android.content.SharedPref ...
- ERROR<53761> - Plugins - conn=-1 op=-1 msgId=-1 - Connection Bind through PTA failed (91). Retrying...
LDAP6.3在DSCC控制台启动实例完成,但是操作状态显示“意外错误”,查看日志如下: 04/May/2016:21:10:39 +0800] - Sun-Java(tm)-System-Direc ...
- hdu 1728
//hdu 1728 //这个是一道很经典的迷宫题了,思路感觉...取起点和终点,判断连线是否超过n个弯, //先是从起点出发,上下左右四个方向搜索,找到一条路,把那条路的第一个点压入队列 //然后沿 ...
- Java HttpClient
public class WebClient { public static final String POST_TYPE_JSON = "json"; public static ...
- java分布式开发,什么是分布式开发
就是同一个服务,把数据库的不同部分分开建立到不同的服务器上.以缓解数据库大量数据访问的压力.很多大公司的业务量比较大,每天的访问量都达到几百万上千万,甚至上亿的访问量,在访问量不是很大的情况下,是可以 ...
- python zip文件密码爆破
#!/usr/bin/env # coding=UTF-8 import zipfile import threading import os import sys class CrackZip: d ...
- print流
PrintWriter和PrintStream都属于输出流,分别针对字符和字节. PrintWriter和PrintStream提供了重载的print,println方法用于多种类型的输出 Print ...
- [BZOJ]3737 [Pa2013]Euler
从这个FB开始写博客啦. 也不知道会坚持多久…… = =似乎要加一句转载请注明出处 http://www.cnblogs.com/DancingOnTheTree/p/4026076.html htt ...
- 思科27亿美元收购网络安全公司Sourcefire
据国外媒体报道,思科于今日宣布将以27亿美元的总价收购网络安全公司Sourcefire,以加强自身在网络安全业务领域的优势,该交易将于今年下半年完成. [IT商业新闻网讯](记者 张良)7月23日消息 ...
- ios视图切换之push与present混用
在变成过程中,经常遇到两个视图控制器之间的切换,导航控制器即UINaVigation是最常用的一种,有时为了某些效果又需要进行模态切换,即present. 我们的布局经常是在window上加一个nav ...