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
76
votes
6 answers

How to detect 386, amd64, arm, or arm64 OS architecture via shell/bash

I'm looking for a POSIX shell/bash command to determine if the OS architecture is 386, amd64, arm, or arm64?
Justin
  • 42,716
  • 77
  • 201
  • 296
75
votes
2 answers

Linux shared memory: shmget() vs mmap()?

In this thread the OP is suggested to use mmap() instead of shmget() to get shared memory in Linux. I visited this page and this page to get some documentation, but the second one gives an obscure example regarding mmap(). Being almost a newbie, and…
BowPark
  • 1,340
  • 2
  • 21
  • 31
74
votes
7 answers

Is there an equivalent to WinAPI's MAX_PATH under linux/unix?

If I want to allocate a char array (in C) that is guaranteed to be large enough to hold any valid absolute path+filename, how big does it need to be. On Win32, there is the MAX_PATH define. What is the equivalent for Unix/linux?
AndrewR
  • 10,759
  • 10
  • 45
  • 56
72
votes
8 answers

How to detect if the current process is being run by GDB

The standard way would be the following: if (ptrace(PTRACE_TRACEME, 0, NULL, 0) == -1) printf("traced!\n"); In this case, ptrace returns an error if the current process is traced (e.g., running it with GDB or attaching to it). But there is a…
terminus
  • 13,745
  • 8
  • 34
  • 37
71
votes
9 answers

POSIX-Compliant Way to Scope Variables to a Function in a Shell Script

Is there a POSIX Compliant way to limit the scope of a variable to the function it is declared in? i.e.: Testing() { TEST="testing" } Testing echo "Test is: $TEST" should print "Test is:". I've read about the declare, local, and typeset…
John
  • 1,671
  • 2
  • 13
  • 14
69
votes
4 answers

How are the O_SYNC and O_DIRECT flags in open(2) different/alike?

The use and effects of the O_SYNC and O_DIRECT flags is very confusing and appears to vary somewhat among platforms. From the Linux man page (see an example here), O_DIRECT provides synchronous I/O, minimizes cache effects and requires you to…
user625070
68
votes
6 answers

Get POSIX/Unix time in seconds and nanoseconds in Python?

I've been trying to find a way to get the time since 1970-01-01 00:00:00 UTC in seconds and nanoseconds in python and I cannot find anything that will give me the proper precision. I have tried using time module, but that precision is only to…
Bill
  • 709
  • 1
  • 6
  • 4
67
votes
1 answer

Why does a read-only open of a named pipe block?

I've noticed a couple of oddities when dealing with named pipes (FIFOs) under various flavors of UNIX (Linux, FreeBSD and MacOS X) using Python. The first, and perhaps most annoying is that attempts to open an empty/idle FIFO read-only will block…
Jim Dennis
  • 17,054
  • 13
  • 68
  • 116
64
votes
12 answers

How much overhead is there when creating a thread?

I just reviewed some really terrible code - code that sends messages on a serial port by creating a new thread to package and assemble the message in a new thread for every single message sent. Yes, for every message a pthread is created, bits are…
jdt141
  • 4,993
  • 6
  • 35
  • 36
61
votes
16 answers

Where are all my inodes being used?

How do I find out which directories are responsible for chewing up all my inodes? Ultimately the root directory will be responsible for the largest number of inodes, so I'm not sure exactly what sort of answer I want.. Basically, I'm running out of…
Joel
  • 11,431
  • 17
  • 62
  • 72
56
votes
6 answers

Converting datetime to POSIX time

How do I convert a datetime or date object into a POSIX timestamp in python? There are methods to create a datetime object out of a timestamp, but I don't seem to find any obvious ways to do the operation the opposite way.
Jason Baker
  • 192,085
  • 135
  • 376
  • 510
55
votes
1 answer

File opening mode in Ruby

I am new programmar in Ruby. Can someone take an example about opening file with r+,w+,a+ mode in Ruby? What is difference between them and r,w,a? Please explain, and provide an example.
amir amir
  • 3,375
  • 7
  • 26
  • 29
55
votes
3 answers

Checking if errno != EINTR: what does it mean?

I've found this piece of code used several times (also a similar one where it's used open() instead of write()). int c = write(fd, &v, sizeof(v)); if (c == -1 && errno != EINTR) { perror("Write to output file"); exit(EXIT_FAILURE); } Why it…
Robb1
  • 4,587
  • 6
  • 31
  • 60
55
votes
4 answers

Is there really no asynchronous block I/O on Linux?

Consider an application that is CPU bound, but also has high-performance I/O requirements. I'm comparing Linux file I/O to Windows, and I can't see how epoll will help a Linux program at all. The kernel will tell me that the file descriptor is…
Jon Watte
  • 6,579
  • 4
  • 53
  • 63
52
votes
2 answers

What is the difference between ssize_t and ptrdiff_t?

The C standard (ISO/IEC 9899:2011 or 9899:1999) defines a type ptrdiff_t in . The POSIX standard (ISO/IEC 9945; IEEE Std 1003.1-2008) defines a type ssize_t in . What is the difference between these types (or why were both…
Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278