亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫(kù)
12
最近訪問(wèn)板塊 發(fā)新帖
樓主: xpkiller
打印 上一主題 下一主題

進(jìn)程間文件加鎖的問(wèn)題 [復(fù)制鏈接]

論壇徽章:
0
11 [報(bào)告]
發(fā)表于 2008-08-07 20:48 |只看該作者
如果是兩個(gè)進(jìn)程的話,用fcntl()設(shè)置鎖,參考APUE 14.3:
#include <fcntl.h>

int fcntl(int filedes, int cmd, ... /* struct
flock *flockptr */ );




Returns: depends on cmd if OK (see following), 1 on error


For record locking, cmd is F_GETLK, F_SETLK, or F_SETLKW. The third argument (which we'll call flockptr) is a pointer to an flock structure.

   struct flock {
     short l_type;   /* F_RDLCK, F_WRLCK, or F_UNLCK */
     off_t l_start;  /* offset in bytes, relative to l_whence */
     short l_whence; /* SEEK_SET, SEEK_CUR, or SEEK_END */
     off_t l_len;    /* length, in bytes; 0 means lock to EOF */
     pid_t l_pid;    /* returned with F_GETLK */
   };

This structure describes

The type of lock desired: F_RDLCK (a shared read lock), F_WRLCK (an exclusive write lock), or F_UNLCK (unlocking a region)

The starting byte offset of the region being locked or unlocked (l_start and l_whence)

The size of the region in bytes (l_len)

The ID (l_pid) of the process holding the lock that can block the current process (returned by F_GETLK only)

論壇徽章:
0
12 [報(bào)告]
發(fā)表于 2008-08-09 21:58 |只看該作者
用fcntl()文件鎖

論壇徽章:
0
13 [報(bào)告]
發(fā)表于 2008-08-10 00:18 |只看該作者
如果B進(jìn)程是你自己寫(xiě)的,那么當(dāng)你不希望B進(jìn)程對(duì)文件進(jìn)行寫(xiě)操作的時(shí)候,為什么會(huì)在B進(jìn)程中加入寫(xiě)文件的代碼???
12
返回列表 發(fā)新帖
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國(guó)互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過(guò)ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP