gpt4 book ai didi

c++ - fcntl() 中的第三个参数是什么

转载 作者:行者123 更新时间:2023-11-30 20:12:42 25 4
gpt4 key购买 nike

我不确定 fcntl() 中的第三个参数,我确实知道当第二个arg改变时它是不同的,当第二个arg是F_GETLK时它是一个指针但是当第二个参数是 F_GETFL 时等等,第三个参数应该是什么?

从 APUE 中,当第二个参数为 F_GETFL 时,它为 0

无论如何,谢谢:)

最佳答案

fcntl() can take an optional third argument. Whether or not this argument is required is determined by cmd. The required argument type is indicated in parentheses after each cmd name (in most cases, the required type is int, and we identify the argument using the name arg), or void is specified if the argument is not required.

F_SETLK, F_SETLKW, and F_GETLK are used to acquire, release, and test for the existence of record locks (also known as byte-range, file- segment, or file-region locks). The third argument, lock, is a pointer to a structure that has at least the following fields (in unspecified order).

As with traditional advisory locks, the third argument to fcntl(), lock, is a pointer to an flock structure. By contrast with traditional record locks, the l_pid field of that structure must be set to zero when using the commands described below.

此链接将帮助您解决问题 http://man7.org/linux/man-pages/man2/fcntl.2.html

关于c++ - fcntl() 中的第三个参数是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34625339/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com