温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

linux应用程序编程应该要学习的函数使用列表

发布时间:2020-07-24 16:02:28 来源:网络 阅读:316 作者:GaoNeil 栏目:移动开发

linux应用程序编程应该要学习的函数使用列表

linux应用层编程相关的man page,具体包括的命令和函数,请参考https://www.kernel.org/doc/man-pages/

select()、pselect()、poll()、epoll(), epoll_create(),epoll_wait(),epoll_ctl(),close()==同时监控多个fd的输入、输出

inotify机制,inotify_init(),inotify_add_watch(),inotify_rm_watch(),read(),epoll_ctl(), close() 监控文件或目录的变化 ==参考代码,android的EventHub.cpp实现。

regcomp()、regexec()、regerror()、regfree()、 ===正则表达式处理

open()、close()、lseek()、read()、write()、dup()、dup2()、ioctl()、sync()、fsync()、fcntl()、ioctl()、stat()、fstat()、umask()、chmod()、chown()、unlink()、utimes、mkdir、fopen()、fclose()、readv、writev(struct iovec)、readn、writen、feof、ferror、fgetc、fgetpos、fgets、fread、ftruncate、truncate ===文件操作
dprintf、vdprintf ===打印到fd上。
fprintf、fputc、fputs、putc、 ===打印到FILE上
putchar、puts、putchar_unlocked、putc_unlocked、
fscanf、fseek、ftell、rewind、fgetpos、fsetpos、fseeko、ftello、 ======FILE文件
fwrite ====写FILE*
getc、getchar、getchar_unlocked、getc_unlocked、ungetc、 gets(此函数deprecated了)
perror、errno、strerror
pread, pwrite ===== read from or write to a file descriptor at a given offset
printf、scanf、snprintf、sprintf 、sscanf、vdprintf、vfprintf、vfscanf、vprintf、vscanf、vsnprintf、vsprintf、vsscanf ====字符串处理函数
readdir、
readlink、readlinkat、symlink、symlinkat ========= symbolic link相关

creat()、openat()、fdatasync()、fstatat()、lstat()、fstat、()、fchmod()、fchmodat()、fchown()、fchownat()、lchown()、link、linkat、unlinkat、opendir、rewinddir、seekdir mkdtemp 创建唯一的temporary directory
mkstemp, mkostemp, mkstemps, mkostemps - create a unique temporary file

remove、rename、renameat、futimens、utimensat、mkdirat、rmdir、chdir、fchdir、getcwd、fdopen、freopen、fdopendir、fflush、telldir、
access()、faccessat检查进程访问文件权限
flockfile、ftrylockfile、funlockfile ==锁FILE
clearerr、feof、ferror、fileno
futimens、utimensat、 改变文件时间戳
strftime、strftime_l、strptime、 格式化日期和时间
fwide 判断FILE
是wide-character oriented或者byte-character oriented
getcwd、getwd、get_current_dir_name 获取当前工作目录
tmpfile、tmpnam、tmpnam_r、
setbuf、setbuffer、setlinebuf、setvbuf =====FILE stream处理函数。

fmemopen、open_memstream、open_wmemstream、 ===open memory as stream

fpathconf、pathconf ===获取文件的配置值

aio_read(struct aiocb, 需要注册信号处理函数)、aio_write、aio_fsync、aio_error、aio_return、aio_suspend、aio_cancel、lio_listio ===异步i/o操作

sysconf()、patchconf()、fpatchconf()、查询配置函数
uname 查询系统名和信息

getrlimit、setrlimit 进程环境函数、包括进程资源限制量

fork、vfork、exit、_exit、wait、waitpid、waitid、wait3、wait4、exec、execl、execle、execlp、execv、execve、execvp、fexecve 、system 进程控制函数
getegid、getgid ==获取进程组identity
getopt、getopt_long、getopt_long_only 用于parse 命令行的输入参数
getenv 获取进程环境变量
geteuid、getuid、seteuid、setreuid 、setuid === 获取user identity
getpgid、setpgid、setpgrp、getpgrp、setegid、setgid、setregid === 设置进程组
getsid、 setsid ==== 获取session id
getpid、getppid === 进程id
signal、kill、alarm 、sigprocmask、sigpending、sigaction、sigsuspend、sigwait、strsignal、abort、system、sleep、nanosleep、clock_nanosleep ==信号函数
psignal, psiginfo、sigemptyset, sigfillset, sigaddset, sigdelset, sigismember、 =====print signal message
atexit、 ===注册退出时回调函数
getpriority、setpriority、nice、sched_setscheduler 获取、设置进程调度优先级。
raise、pause、sigqueue、sigsetjmp、siglongjmp、
setjmp、sigsetjmp、longjmp、siglongjmp stack context控制函数,如果调用者返回,那么保存的环境就invalidated了

/etc/group 、 getgrent、endgrent、setgrent、getgrgid、getgrnam、getgrnam_r、getgrgid_r 、getgroups、setgroups、initgroups === 用户组相关信息的函数 本机中的所有用户组信息。
getlogin、getlogin_r、cuserid 获取用户名

pthread_create、pthread_exit、pthread_join、pthread_atfork、pthread_cleanup、pthread_equal、pthread_cond_init、pthread_cond_signal、pthread_cond_broadcast、pthread_cond_wait、pthread_cond_timedwait、pthread_cond_destroy、pthread_attr_init、pthread_attr_xxx系列函数、pthread_mutex_init、pthread_mutex_xxx系列函数、pthread_barrierattr_xxx系列函数、pthread_barrier_xxx系列函数、pthread_condattr_xxx系列函数、pthread_cond_xxx系列函数、pthread_detach、pthread_mutexattr_xxx系列函数、pthread_rwlockattr_xxx系列函数、pthread_rwlock_xxx系列函数、pthread_spin_xxx系列函数、pthread_sigmask、 ==== pthread系列函数
pthread_mutex_timedlock

sem_close 、sem_destroy、sem_getvalue、sem_init、sem_open、sem_post、sem_timedwait、sem_trywait、sem_unlink、sem_wait、 ====同步机制 信号量semaphore、

popen、pclose、pipe、mkfifo、 进程间通信(管道、fifo、system v ipc(包括共享内存、消息队列、信号灯))
mkfifoat、
msgget、semget、semctl、semop、shmget、shmat、shmctl、shmdt、、msgctl、msgrcv、msgsnd、
ftok、

socket、socketpair、accept、bind、connect、listen、shutdown、send、sendmsg、sendto、recvmsg、recv、recvfrom既然socket也是个fd所以也可以使用read、write、select等 socket通信、进程间通信
getsockopt、setsockopt、 获取或者设置socket option
htonl、htons、ntohl、ntohs、
inet_ntop、inet_pton、 ipv4、ipv6地址 文本和二进制格式转换。
getpeername、
getaddrinfo、freeaddrinfo、gai_strerror、gethostbyname、getservbyname 网络地址和服务转换
gethostname、sethostname
gethostbyname, gethostbyaddr, sethostent, gethostent, endhostent, h_errno, herror, hstrerror, gethostbyaddr_r, gethostbyname2, gethostbyname2_r, gethostbyname_r, getsockname、
gethostent_r 获取network host entry
sockatmark、

getnameinfo、getservbyport、getnetbyaddr、getnetbyname、getnetent、setnetent、endnetent、 关于network entry相关
getservent、getservbyname、getservbyport、setservent、endservent 获取service entry

tcflush、tcsetattr、cfgetispeed、 cfgetospeed、cfsetispeed、 cfsetospeed 、isatty 串口通信
termios, tcgetattr, tcsetattr, tcsendbreak, tcdrain, tcflush, tcflow, cfmakeraw, cfgetospeed, cfgetispeed, cfsetispeed, cfsetospeed, cfsetspeed ===get and set terminal attributes, line control, get and set baud rate
tcgetpgrp、tcsetpgrp、tcgetsid
ttyname、ttyname_r

malloc、calloc、free、brk、sbrk、realloc 堆内存分配函数

mmap、munmap、msync、mprotect、mremap ===内存映射 相关

clock_getres、clock_gettime、clock_settime、clock_nanosleep、 === clock和time相关函数
nanosleep、usleep、sleep === sleep一定时间函数
gettimeofday、settimeofday === get/set time
asctime, ctime, gmtime, localtime, mktime, asctime_r, ctime_r, gmtime_r, localtime_r 、struct tm、time_t ===转换transform date and time to broken-down time or ASCII
time、
times、 get process time

/etc/protocols 、 getprotobyname、getprotobynumber、getprotoent、setprotoent、endprotoent 获取协议entry 本主机中的所有协议。

/etc/passwd、NIS、LDAP等管理密码相关的函数、 getpwent、setpwent、endpwent、getpwnam、getpwuid、getpwname_r、getpwuid_r 获取password file entry(包括用户名、password、用户id、组id、用户信息、home目录、shell program)。

getspnam, getspnam_r, getspent, getspent_r, setspent, endspent, fgetspent, fgetspent_r, sgetspent, sgetspent_r, putspent, lckpwdf, ulckpwdf ===get shadow password file entry

closelog, openlog, syslog, vsyslog、setlogmask ===== send messages to the system logger

posix_openpt、grantpt、ptsname、unlockpt、 psy伪终端相关

putenv、setenv 、unsetenv ===修改或增加环境变量

具体文档链接见:
链接: https://pan.baidu.com/s/1LHslhWLwx7hwvzky7czHHw 提取码: keh3

另外我的相关培训视频请看:
欢迎观看我发布的各个课程: https://edu.51cto.com/lecturer/8896847.html

另外我的免费的linux各种驱动开发课程如下:
https://edu.51cto.com/course/17138.html

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI