Questions tagged [posix]

POSIX (Portable Operating System Interface) is a set of standards defining programming APIs, a command interpreter, and common utilities for Unix-like operating systems.

POSIX (an acronym for "Portable Operating System Interface") is a family of standards that specifies the behaviour of Unix-like operating systems.

These standards define:

  • A standard operating system interface and environment
  • A programming API for the C programming language
  • The behavior of a command interpreter (or "shell")
  • The behavior of common utility programs invocable from the shell

The POSIX standards are developed by the Austin Common Standards Revision Group, a joint technical working group led by representatives from IEEE PASC, ISO/IEC JTC 1/SC 22, and The Open Group.

The current set of POSIX standards is available online.

POSIX is a trademark of the IEEE.

5973 questions
3
votes
4 answers

"thread fork" in C (ideally POSIX, but just Linux works)

Are there any libraries/pthread wrappers/clone arguments that would allow me to have a tfork--something that, just like fork(), allows you to continue code execution in context, as opposed to pointing to a new function to execute under a new…
Aaron Yodaiken
  • 19,163
  • 32
  • 103
  • 184
3
votes
1 answer

Why does an exiting child process cause the parent's sigsuspend call to return on macOS?

Consider the following C code for a POSIX system: #include #include #include #include #define CONTINUE_SIGNAL SIGINT void continue_handler(int sig, siginfo_t *info, void *context) { printf("[P]…
user13702657
3
votes
2 answers

Should I expect POSIX to include getopt.h?

According to this, the POSIX library does not include getopt.h. However, I found this in unistd.h: #ifdef __USE_POSIX2 /* Get definitions and prototypes for functions to process the arguments in ARGV (ARGC of them, minus the program name) for …
someguy
  • 7,144
  • 12
  • 43
  • 57
3
votes
3 answers

How to properly remove Mutex?

Using C++, in one of my destructors, i say mutex = NULL; This however results in an error "No viable overloaded '='" in my Xcode. Same mutex was previously initialized in a constructor as mutex = PTHREAD_MUTEX_INITIALIZER; Please advise, how can i…
James Raitsev
  • 92,517
  • 154
  • 335
  • 470
3
votes
3 answers

Issue with timer with long signal handler (SIGALARM)

There is a timer which sends out signal SIGALARM every 1 sec. A signal handler which sleeps 2 sec is registered. What happens? Specifically, I have following code, in which the process runs multiple threads. It's quite interesting that with this…
Richard
  • 14,642
  • 18
  • 56
  • 77
3
votes
1 answer

POSIX TIMER- Have multiple timers

I am trying to have two timers in my system for two different purpose but I dont understand why it doesnt work. Can somebody help me?Also, Should the handler code be a bare minumum so the tasks themselves dont interfere with the tick? Also can I…
user489152
  • 907
  • 1
  • 23
  • 42
3
votes
1 answer

Send and receive UDP multicast packets with the same socket

I could not find a working example for this, so I am going to post a question (and let's see if I can reduce this to an MVP code example). So, I need to do mdns queries, I can use two sockets (one for sending / second for receiving) but so far I…
Rudolfs Bundulis
  • 11,636
  • 6
  • 33
  • 71
3
votes
1 answer

Using POSIX message queues for intra-process communication

I am designing a single-process multi-threaded embedded Linux application. The design includes client-server subsystem where a worker thread receives messages posted by other threads on a POSIX message queue. I need the queue to exhibit non-blocking…
3
votes
1 answer

Simple example for aio_write()

I'm searching for a simple example for the POSIX aio_write function. What I tried so far The below is not too important. Just jump to answer The code below creates a file, but does not write anything to it. aio_error returns 22 (= quota exceeded,…
DarkTrick
  • 2,447
  • 1
  • 21
  • 39
3
votes
5 answers

feeding data to C API expecting a filename

I'm writing a straightforward C program on Linux and wish to use an existing library's API which expects data from a file. I must feed it a file name as a const char*. But i have data, just like content of a file, already sitting in a buffer…
DarenW
  • 16,549
  • 7
  • 63
  • 102
3
votes
2 answers

Proper message queue usage in POSIX

I'm quite bewildered by the use of message queues in realtime OS. The code that was given seems to have message queues used down to the bone: even passing variables to another class object is done through MQ. I always have a concept of MQ used in…
freonix
  • 1,605
  • 3
  • 22
  • 35
3
votes
2 answers

Can strnlen be implemented with memchr?

Is the implementation of strnlen that follows invalid? size_t strnlen(const char *str, size_t maxlen) { char *nul = memchr(str, '\0', maxlen); return nul ? (size_t)(nul - str) : maxlen; } I assume that memchr may always look at maxlen bytes…
JudeMH
  • 485
  • 2
  • 10
3
votes
1 answer

How to determine size for multiple ancillary messages in linux control messages

I try to send multiple file descriptors over a unix socket at once. This is no problem for a single socket. Although when I try to append another one with CMSG_NXTHDR I get back a null pointer that indicates that my buffer was too short. For one…
jklmnn
  • 481
  • 1
  • 5
  • 11
3
votes
1 answer

What is the return value of spurious wake-ups?

In C11, the cnd_timedwait function is defined as followed: int cnd_timedwait( cnd_t* restrict cond, mtx_t* restrict mutex, const struct timespec* restrict time_point ); Atomically unlocks the mutex pointed to by mutex and blocks…
b1105029
  • 161
  • 1
  • 4
3
votes
1 answer

Matching forward slash in regex

I've troubles with preparing regex expression, matching forward slash ('/') inside. I need to match string like "/ABC6" (forward slash, then any 3 characters, then exactly one digit). I tried expressions like "^/.{3}[0-9]", "^\/.{3}[0-9]",…
VillageTech
  • 1,968
  • 8
  • 18