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
23
votes
4 answers

Atomicity of `write(2)` to a local filesystem

Apparently POSIX states that Either a file descriptor or a stream is called a "handle" on the open file description to which it refers; an open file description may have several handles. […] All activity by the application affecting the file…
kmkaplan
  • 18,655
  • 4
  • 51
  • 65
22
votes
8 answers

Detecting a chroot jail from within

How can one detect being in a chroot jail without root privileges? Assume a standard BSD or Linux system. The best I came up with was to look at the inode value for "/" and to consider whether it is reasonably low, but I would like a more accurate…
Topaz
  • 233
  • 1
  • 3
  • 8
22
votes
1 answer

MAP_ANONYMOUS with C99 standard

I have an application that uses the mmap system call, I was having an issue getting it to compile for hours looking as to why I was getting MAP_ANON and MAP_ANONYMOUS were undeclared, I had a smaller section of code that I used and I saw I could…
Jesus Ramos
  • 22,940
  • 10
  • 58
  • 88
22
votes
2 answers

What does the "ve" in "execve" mean?

What does the ve in execve mean? I read through man execve but didn't see what it means. I gather it might be "vector" but not sure. What does the ve mean?
Elijah Lynn
  • 12,272
  • 10
  • 61
  • 91
22
votes
1 answer

munmap() failure with ENOMEM with private anonymous mapping

I have recently discovered that Linux does not guarantee that memory allocated with mmap can be freed with munmap if this leads to situation when number of VMA (Virtual Memory Area) structures exceed vm.max_map_count. Manpage states this (almost)…
user1143634
22
votes
6 answers

Defining PATH_MAX for a filesystem?

I'm presently writing a filesystem. The statvfs (and even the statfs) structs contain a field specifying the maximum length of a name in that path. As PATH_MAX is defined in the pathconf manpage (getconf), this means it is defined on a per-directory…
Matt Joiner
  • 112,946
  • 110
  • 377
  • 526
22
votes
1 answer

What is the difference between locking with `fcntl` and `flock`?

I'm reading for hours but can't understand what is the difference between the two locks. The only thing I understand is that fcntl() lock is offering a granular lock that can lock specific bytes and that only fcntl() supports NFS locking. It's said…
Quaker
  • 1,483
  • 3
  • 20
  • 36
22
votes
4 answers

Is Android POSIX-compatible?

Is Android POSIX-compatible? I know it uses the Linux kernel, but I'm not sure if that means it's POSIX compatible, as the POSIX standard deals more with userland functions. So, is it compatible? For example, if I use only ANSI and POSIX functions…
sashoalm
  • 75,001
  • 122
  • 434
  • 781
22
votes
6 answers

Since we have snprintf, why we don't have a snscanf?

I have snprintf and it can avoid a buffer overflow, but why there is no function called snscanf? Code: int main() { char * src = "helloeveryone"; char buf1[5]; sscanf(src,"%s",buf1); // here is a array out of bounds } So, I think a…
Lidong Guo
  • 2,817
  • 2
  • 19
  • 31
22
votes
3 answers

Monotonic clock on OSX

CLOCK_MONOTONIC does not seem available, so clock_gettime is out. I've read in some places that mach_absolute_time() might be the right way to go, but after reading that it was a 'cpu dependent value', it instantly made me wonder if it is using…
Brett
  • 4,066
  • 8
  • 36
  • 50
21
votes
4 answers

Why does \$ reduce to $ inside backquotes [though not inside $(...)]?

Going over the POSIX standard, I came across another rather technical/pointless question. It states: Within the backquoted style of command substitution, shall retain its literal meaning, except when followed by: '$' , '`' , or…
ezequiel-garzon
  • 3,047
  • 6
  • 29
  • 33
21
votes
2 answers

What are the WONTFIX bugs on GNU/Linux and how to work around them?

Both Linux and the GNU userspace (glibc) seem to have a number of "WONTFIX" bugs, i.e. bugs which the responsible parties have declared their unwillingness to fix despite clearly violating the requirements of ISO C and/or POSIX, but I'm unaware of…
R.. GitHub STOP HELPING ICE
  • 208,859
  • 35
  • 376
  • 711
21
votes
3 answers

What posix_fadvise() args for sequential file write?

I am working on an application which does sequentially write a large file (and does not read at all), and I would like to use posix_fadvise() to optimize the filesystem behavior. The function description in the manpage suggests that the most…
Michał Górny
  • 18,713
  • 5
  • 53
  • 76
21
votes
5 answers

Can time(NULL) ever return failure?

Can the time_t time(time_t *t) function ever return failure if the argument passed is always NULL? If the call is time(NULL), do we still need to check for the return value? The only documented error code is EFAULT, which relates to the pointer…
Jay
  • 24,173
  • 25
  • 93
  • 141
21
votes
2 answers

What to do if a posix close call fails?

On my system (Ubuntu Linux, glibc), man page of a close call specifies several error return values it can return. It also says Not checking the return value of close() is a common but nevertheless serious programming error. and at the same…
Ilya Popov
  • 3,765
  • 1
  • 17
  • 30