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
37
votes
2 answers

How to read a line from stdin, blocking until the newline is found?

I'm trying to read one line at a time, of arbitrary length, from stdin at the command line. I'm not sure if I'll be able to include GNU readline and would prefer to use a library function. The documentation I've read suggests that getline ought to…
Taymon
  • 24,950
  • 9
  • 62
  • 84
36
votes
4 answers

What size should I allow for strerror_r?

The OpenGroup POSIX.1-2001 defines strerror_r, as does The Linux Standard Base Core Specification 3.1. But I can find no reference to the maximum size that could be reasonably expected for an error message. I expected some define somewhere that I…
mat_geek
  • 2,481
  • 3
  • 24
  • 29
36
votes
2 answers

Why does start_routine for pthread_create return void* and take void*

The function header for pthread_create looks like this: int pthread_create(pthread_t * thread, const pthread_attr_t * attr, void * (*start_routine)(void *), void *arg); I understand it all…
ldog
  • 11,707
  • 10
  • 54
  • 70
35
votes
5 answers

What is the equivalent to Posix popen() in the Win32 API?

Is there a rough equivalent to the Linux/Unix stdio.h popen() function in the Win32 API? If so, where can I find it? Edit: I need to know this to patch an omission in the D standard library. Any answer must use only standard Win32 API, no…
dsimcha
  • 67,514
  • 53
  • 213
  • 334
34
votes
6 answers

How to redirect the output back to the screen after freopen("out.txt", "a", stdout)

#include int main() { printf("This goes to screen\n"); freopen("out.txt", "a", stdout); printf("This goes to out.txt"); freopen("/dev/stdout", "a", stdout); printf("This should go to screen too, but doesn't\n"); …
Hoffmann
  • 14,369
  • 16
  • 76
  • 91
33
votes
2 answers

Connecting n commands with pipes in a shell?

I am trying to implement a shell in C. I can execute simple commands just fine with a simple execvp() but one of the requirements is to manage commands like this: "ls -l | head | tail -4" with a 'for' loop and only one 'pipe()' statement redirecting…
vicpermir
  • 3,544
  • 3
  • 22
  • 34
33
votes
3 answers

Why did POSIX mandate CHAR_BIT==8?

There's a note in the POSIX rationale that mandating CHAR_BIT be 8 was a concession made that was necessary to maintain alignment with C99 without throwing out sockets/networking, but I've never seen the explanation of what exactly the conflict was.…
R.. GitHub STOP HELPING ICE
  • 208,859
  • 35
  • 376
  • 711
33
votes
4 answers

Are socket options inherited across accept() from the listening socket?

Suppose the listening socket passed to accept has non-default options set on it with setsockopt. Are these options (some or all of them?) inherited by the resulting file descriptors for accepted connections?
R.. GitHub STOP HELPING ICE
  • 208,859
  • 35
  • 376
  • 711
33
votes
6 answers

getline() vs. fgets(): Control memory allocation

To read lines from a file there are the getline() and fgets() POSIX functions (ignoring the dreaded gets()). It is common sense that getline() is preferred over fgets() because it allocates the line buffer as needed. My question is: Isn’t that…
edavid
  • 371
  • 1
  • 3
  • 5
33
votes
4 answers

Differences between System V and Posix semaphores

What are the trade-offs between using a System V and a Posix semaphore?
corto
  • 2,657
  • 4
  • 21
  • 9
33
votes
2 answers

How do you capture a group with regex?

I'm trying to extract a string from another using regex. I'm using the POSIX regex functions (regcomp, regexec ...), and I fail at capturing a group ... For instance, let the pattern be something as simple as "MAIL FROM:<(.*)>" (with REG_EXTENDED…
Sylvain
  • 3,202
  • 5
  • 27
  • 27
33
votes
7 answers

UNIX Portable Atomic Operations

Is there a (POSIX-)portable way in C for atomic variable operations similar to a portable threading with pthread? Atomic operations are operations like "increment and get" that are executed atomically that means that no context switch can interfere…
dmeister
  • 34,704
  • 19
  • 73
  • 95
32
votes
2 answers

Which systems define EAGAIN and EWOULDBLOCK as different values?

Just curious. Which systems providing both EAGAIN and EWOULDBLOCK #define them as different values?
pilcrow
  • 56,591
  • 13
  • 94
  • 135
32
votes
3 answers

Where is the list of the POSIX C API functions?

I'm trying to find out where I can find documentation on POSIX functions, but coming up short. Any recommendations?
saturday night
32
votes
6 answers

Is assert(false) ignored in release mode?

I am using VC++. Is assert(false) ignored in release mode?
Brian R. Bondy
  • 339,232
  • 124
  • 596
  • 636