Skip to content
Advertisement

Tag: posix

Should mqueues be protected by semaphores

Should read mq_receive and write mq_send be protected by semaphores when accessing a queue in a multiprocess program or is there any sort of protection alredy built in Answer It’s always recomended to read the formal documentation for API you are using. Specifcally for mq_receive and mq_send these are: https://man7.org/linux/man-pages/man3/mq_send.3.html https://man7.org/linux/man-pages/man3/mq_receive.3.html In the atributes section you can see that both

C program to mkdir in POSIX shared memory missing permissions

I have a POSIX shared memory directory which gets blown away on reboot and needs to be recreated on occasion. An example, This creates the directory with missing write permissions for group/others: I’ve tried experimenting with the mode_t flags and even replaced “0777” with “S_IRWXU | S_IRWXG | S_IRWXO”. I do need the directory to have permission flag 0777. Answer

read directories withoud readdir

I’m working on POSIX linux to learn. I’m using C Programming Languages. I want to read a folder, but instead of using readdir or opendir, I want to use pure open and read, I want to extract subfolders or files in this folder as names as string. Is this possible with open() and read() as open and read (without using

Race condition on pthread_kill()?

Linux manual for pthread_kill() has the following paragraph: POSIX.1-2008 recommends that if an implementation detects the use of a thread ID after the end of its lifetime, pthread_kill() should return the error ESRCH. The glibc implementation returns this error in the cases where an invalid thread ID can be detected. But note also that POSIX says that an attempt to

How to use SIGEV_THREAD, sigevent for linux-timer(s) expiration handling in C?

Problem: I have timer(s) running, upon expiration of timer(s) certain function needs to be invoked. Output: There is a segfault inside Hndlr() function As per man page of sigevent, it says, SIGEV_THREAD – Notify the process by invoking sigev_notify_function “as if” it were the start function of a new thread. (Among the implementā€ tation possibilities here are that each timer

POSIX shared memory model

Is there a memory model specification for POSIX shared memory (across processes)? I’m hoping that there’s something to comparable to the C++ memory model, in order to answer questions like the following: Is there a definition of a data race? Are data races undefined behavior (as in C++)? Is there something to constrain memory visibility order across processes? I know

POSIX open() hangs on SMB share

I have a problem where I mount a Windows SMB share under linux with mount.cifs and write to files from my C++ program. This works fine, but as soon as network problems arise (i.e. Windows server disconnect), opening the file with POSIX open() will hang indefinitely. The same happens for the POSIX close() call if the share disconnects while the

C/C++: POSIX compatible way to find default network interface up/down

I’m working on POSIX platform (PSE51 to be exact). I want to get notified when the default network interface goes up/down (via a callback or through continuous poll). The challenge is that I could find a linux specific way to get the default interface here and found a linux specific way to find the network is up or down here

Wait for signal from parent and does job and blocks again

Write a program that can display a text string (consisting only of the 26 alphabets and spaces). The program should fork 27 worker processes. Each worker process runs an infinite loop in which it waits for a signal from the controller (i.e., parent), sleeps for 1 sec, prints its pre-defined character, signals the controller, then blocks again. The controller reads

Advertisement