---
title: "Discussion on \"Linux fcntl Filelock 中的小坑：在同一 Process 不能跨 Thread 使用\" | Hashnode"
description: "Discussion on \"Linux fcntl Filelock 中的小坑：在同一 Process 不能跨 Thread 使用\". 在 Linux 系統下，我們可以透過 fcntl 來提供跨 Process 的 Read/Write Filelock，但是卻有一個小小的坑需要注意，那就是在同一個 Process 內，不可以跨 Thread 使用這個 Lock。\n\n\n舉個例子，假設我們有一個 Process A，會定期地更新 /srv/mydata 這個資料夾，當更新時，會去使用 WLock /srv/mydata.lock 來"
url: "https://hashnode.com/posts/linux-fcntl-filelock-process-thread/643408107a6ecaa1407251bb"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Linux fcntl Filelock 中的小坑：在同一 Process 不能跨 Thread 使用](https://notes.mukyu.dev/linux-fcntl-filelock-process-thread?utm_source=hashnode&utm_medium=feed)

在 Linux 系統下，我們可以透過 fcntl 來提供跨 Process 的 Read/Write Filelock，但是卻有一個小小的坑需要注意，那就是在同一個 Process 內，不可以跨 Thread 使用這個 Lock。 舉個例子，假設我們有一個 Process A，會定期地更新 /srv/mydata 這個資料夾，當更新時，會去使用 WLock /srv/mydata.lock 來

Apr 10, 2023 · 1 min read · notes.mukyu.dev  
Updated Oct 27  
Read the article

-   [#linux](https://hashnode.com/tag/linux)
-   [#c](https://hashnode.com/tag/c)

## Written by

[Patchouli](https://hashnode.com/@mudream4869)

@mudream4869 · Uohout

  
[View profile](https://hashnode.com/@mudream4869)

工程師帕秋莉~

後端工程師。 不定時張貼一些寫扣時的筆記，有時英文，有時中文。 「如果，我是魔女的話...」

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
