mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:27:44 +00:00
LibC: Implement `flockfile
and
funlockfile
`
To do this, we must set the type attribute when initializing a FILE to ``__PTHREAD_MUTEX_RECURSIVE``.
This commit is contained in:
parent
aa0db4e4b0
commit
8515d7d5ab
2 changed files with 11 additions and 10 deletions
|
@ -19,7 +19,8 @@ public:
|
|||
: m_fd(fd)
|
||||
, m_mode(mode)
|
||||
{
|
||||
__pthread_mutex_init(&m_mutex, nullptr);
|
||||
pthread_mutexattr_t attr = { __PTHREAD_MUTEX_RECURSIVE };
|
||||
__pthread_mutex_init(&m_mutex, &attr);
|
||||
}
|
||||
~FILE();
|
||||
|
||||
|
@ -31,6 +32,9 @@ public:
|
|||
void purge();
|
||||
bool close();
|
||||
|
||||
void lock();
|
||||
void unlock();
|
||||
|
||||
int fileno() const { return m_fd; }
|
||||
bool eof() const { return m_eof; }
|
||||
int mode() const { return m_mode; }
|
||||
|
@ -115,9 +119,6 @@ private:
|
|||
// Flush *some* data from the buffer.
|
||||
bool write_from_buffer();
|
||||
|
||||
void lock();
|
||||
void unlock();
|
||||
|
||||
int m_fd { -1 };
|
||||
int m_mode { 0 };
|
||||
u8 m_flags { Flags::None };
|
||||
|
@ -126,8 +127,6 @@ private:
|
|||
pid_t m_popen_child { -1 };
|
||||
Buffer m_buffer;
|
||||
__pthread_mutex_t m_mutex;
|
||||
|
||||
friend class ScopedFileLock;
|
||||
};
|
||||
|
||||
class ScopedFileLock {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue