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
46
votes
10 answers

What's the easiest way to get a user's full name on a Linux/POSIX system?

I could grep through /etc/passwd but that seems onerous. 'finger' isn't installed and I'd like to avoid that dependency. This is for a program so it would be nice if there was some command that let you just access user info.
Josh Gibson
  • 21,808
  • 28
  • 67
  • 63
46
votes
7 answers

Linux and I/O completion ports?

Using winsock, you can configure sockets or seperate I/O operations to "overlap". This means that calls to perform I/O are returned immediately, while the actual operations are completed asynchronously by separate worker threads. Winsock also…
someguy
  • 7,144
  • 12
  • 43
  • 57
45
votes
15 answers

What are some interesting C/C++ libraries to play around with?

I'm looking for a few new libraries and for C and C++. In the past most of the time I "accidently" stumbled across a few - and most of them found good use in projects I worked on. Libraries should run on Mac OS X and Linux/POSIX and possibly on…
BastiBen
  • 19,679
  • 11
  • 56
  • 86
44
votes
7 answers

How to get the username in C/C++ in Linux?

How can I get the actual "username" without using the environment (getenv, ...) in a program? Environment is C/C++ with Linux.
Zat42
  • 2,471
  • 4
  • 22
  • 36
44
votes
3 answers

GCC with -std=c99 complains about not knowing struct timespec

When I try to compile this on Linux with gcc -std=c99, the compiler complains about not knowing struct timespec. However if I compile this without -std=c99 everything works fine. #include int main(void) { struct timespec asdf; return…
Nils
  • 13,319
  • 19
  • 86
  • 108
41
votes
3 answers

Where to place Unix Domain (AF_UNIX) sockets' end points (files)?

Is there a convention where to place the 'files' representing the end points to Unix Domain Sockets? I tend to put them to /tmp/some-application-specific-subdir-name/, but I wonder if there is a more common place. The background is, that POSIX is…
alk
  • 69,737
  • 10
  • 105
  • 255
41
votes
2 answers

waitpid, wnohang, wuntraced. How do I use these

I am a bit confused. As I understand, waitpid with a pid of -1 means that I wait for all child's to finish but if I add an option to the waitpid of WNOHANG, that options says to exit immediately if none have finished...These seems extremely…
8this
  • 485
  • 1
  • 5
  • 9
41
votes
1 answer

What does WEXITSTATUS(status) return?

I am trying to understand how WEXITSTATUS(status) works. I have come across a piece of code where the return value of WEXITSTATUS(status) is being added to a variable. Here is the snippet: waitpid(-1, &status, 0); counter +=…
shaveenk
  • 1,983
  • 7
  • 25
  • 37
41
votes
3 answers

equivalent of pipefail in dash shell

Is there some similar option in dash shell corresponding to pipefail in bash? Or any other way of getting a non-zero status if one of the commands in pipe fail (but not exiting on it which set -e would). To make it clearer, here is an example of…
Lavya
  • 1,475
  • 2
  • 17
  • 21
40
votes
4 answers

Create statically-linked binary that uses getaddrinfo?

I have included the header netdb.h, where getaddrinfo is included, but gcc issues this warning: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking gcc -m32…
Neeladri Vishweswaran
  • 1,695
  • 5
  • 22
  • 40
39
votes
11 answers

Delete all SYSTEM V shared memory and semaphores on UNIX-like systems

How can I delete all not used semaphores and shared memory with a single command on a UNIX-like system, e.g., Ubuntu?
simone
  • 801
  • 2
  • 13
  • 25
39
votes
11 answers

Why does GCC-Windows depend on cygwin?

I'm not a C++ developer, but I've always been interested in compilers, and I'm interested in tinkering with some of the GCC stuff (particularly LLVM). On Windows, GCC requires a POSIX-emulation layer (cygwin or MinGW) to run correctly. Why is…
benjismith
  • 16,559
  • 9
  • 57
  • 80
38
votes
2 answers

Is it allowed to name a global variable `read` or `malloc` in C++?

Consider the following C++17 code: #include int read; int main(){ std::ios_base::sync_with_stdio(false); std::cin >> read; } It compiles and runs fine on Godbolt with GCC 11.2 and Clang 12.0.1, but results in runtime error if…
yeputons
  • 8,478
  • 34
  • 67
37
votes
5 answers

How do I find the current machine's full hostname in C (hostname and domain information)?

In a C project (POSIX), how do I get the fully qualified name for the current system? For example, I can get just the hostname of my machine by doing gethostname() from unistd.h. This might give me machine3 in return, but I'm actually looking for…
Zxaos
  • 7,791
  • 12
  • 47
  • 61
37
votes
3 answers

categories and standard/system error codes

C++11 introduced the header containing a generic system to handle error codes. An std::error_code is a tuple containing an int, the error code, and a reference to an std::error_category, which defines the error domain and handling of…
moatPylon
  • 2,103
  • 1
  • 15
  • 22