码迷,mamicode.com
首页 >  
搜索关键字:fcntl    ( 291个结果
fcntl函数加文件锁
对文件加锁是原子性的,可以用于进程间文件操作的同步。在linux下,有三个函数可以对文件进程加锁,分别是fcntl、flock、lockf。这里只说fcntl,它的用法也是最复杂的。 fcntl是file control的缩写。在linux下大部分设备都是文件,所以fcntl的功能也比较多,包...
分类:其他好文   时间:2015-02-07 22:57:24    阅读次数:275
C串口通信
目录1、串口配置函数2、打开串口3、读写串口总结:这些程序都是从书上抄来的,都是最最简单的程序,写在这里只是想写个大概的思路,具体的函数说明可以看书,其中值得说的就是两个函数,一个是fcntl(fd,F_SETFL,0)//恢复串口为阻塞模式还有一个是select(fd+1,&rd,NULL,NUL...
分类:其他好文   时间:2015-01-29 11:50:32    阅读次数:195
用fcntl()设置堵塞函数的堵塞性质
#include #include #include #include #include #include #include #define ERR_EXIT(m) \ do { \ perror(m);\ exit(EXIT_FAILURE);\ }whil...
分类:其他好文   时间:2015-01-24 18:36:52    阅读次数:201
linux下的键盘检测
话说,仅仅是一个键盘检测就好麻烦。我还是懂的太少了。。。 #include?<stdio.h> #include?<stdlib.h> #include?<unistd.h> #include?<errno.h> #include?<fcntl.h> #include?<stdio.h> #include?<termio...
分类:系统相关   时间:2015-01-08 21:44:20    阅读次数:283
Linux互斥与同步应用(六):文件锁
【版权声明:尊重原创,转载请保留出处:blog.csdn.net/shallnet 或 .../gentleliu,文章仅供学习交流,请勿用于商业用途】             当一个系统中存在多个进程同时操作同一个文件时,为了保证数据的正确, 一般会将文件上锁来避免共享文件产生的竞争状态。在linux系统下文件上锁可以使用fcntl函数来实现。 函数fcntl原型如下: ...
分类:系统相关   时间:2015-01-07 00:44:01    阅读次数:324
C语言函数参数既做出参又做入参的代表
//使用fcntl对文件进行加锁#include "stdio.h"#include "unistd.h"#include "fcntl.h"intmain(){ intfd; structflocklk; intr; fd=open("a.txt",O_RDWR); if(fd==-1) { fd...
分类:编程语言   时间:2014-12-23 12:02:14    阅读次数:438
python 获取本机ip地址的方法(Unix 平台)
1 #!/usr/bin/python 2 import socket 3 import fcntl 4 import struct 5 def get_ip_address(ifname): 6 s = socket.socket(socket.AF_INET, socket.SOCK_...
分类:编程语言   时间:2014-12-22 11:04:27    阅读次数:192
《网络编程》ioctl 操作
ioctl 函数和 fcntl 函数类似,都可用于对描述符的操作,获取或设置已打开描述符的属性,但是两个函数在网络编程相关中操作针对不同了类型,fcntl 函数有套接字操作、文件操作,而 ioctl 函数除了可以操作 fcntl 函数可操作的类型之外,还可以进行接口操作、路由表操作、 ARP 高速缓存操作以及流系统操作。...
分类:其他好文   时间:2014-12-17 18:37:46    阅读次数:151
Linux-Function-fcntl (一);
Name------------fcntl int fcntl(int fd, int cmd, ... /*arg*/) - ---------------manipulate file descriptor/*操作文件描述符*/ //要包含头文件: #include #incl...
分类:系统相关   时间:2014-12-07 01:18:11    阅读次数:444
python 分析redis
#!/usr/bin/envpython#coding=utf-8importMySQLdbimportredisimportosimportsocket,fcntl,struct#printredis._file_defget_ip_address(ifname):s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)returnsocket.inet_ntoa(fcntl.ioctl(s.fileno(),0x8915,#SIOCGIFADDRstruct.pa..
分类:编程语言   时间:2014-12-04 15:50:08    阅读次数:194
291条   上一页 1 ... 23 24 25 26 27 ... 30 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!