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

boost::this_thread::sleep() vs. nanosleep()?

I recently came across the need to sleep the current thread for an exact period of time. I know of two methods of doing so on a POSIX platform: using nanosleep() or using boost::this_thread::sleep(). Out of curiosity more than anything else, I was…
Justin Ardini
  • 9,768
  • 2
  • 39
  • 46
21
votes
1 answer

What is path //, how is it different from /

We know root directory is /, and according to posix, there is another directory // which differs from /. When you ls / and ls //, the output is the same, so as stat, however if you cd / and cd //, they are different, though the directory content are…
dspjm
  • 5,473
  • 6
  • 41
  • 62
21
votes
5 answers

Why is the st_size field in struct stat signed?

st_size is defined as being an off_t. off_t is defined as being a signed integer type. Why is st_size defined as a signed type? Can it be negative? What does it mean if it is negative?
user1290696
  • 489
  • 1
  • 4
  • 10
20
votes
1 answer

If close(2) fails with EIO, will the file descriptor still be deleted?

If a close(2) system call fails with EIO, will the file descriptor still be deleted? If yes, is it not possible to handle a spurious IO error by retrying later? If no, how should one prevent a file descriptor leak?
fornwall
  • 2,877
  • 3
  • 25
  • 38
20
votes
3 answers

How to extract the correct timezones from POSIXct and POSIXlt objects?

time1 = as.POSIXlt("2010-07-01 16:00:00", tz="Europe/London") time1 # [1] "2010-07-01 16:00:00 Europe/London" but time2 = as.POSIXct("2010-07-01 16:00:00", tz="Europe/London") time2 # [1] "2010-07-01 16:00:00 BST" Why is the timezone presented…
RockScience
  • 17,932
  • 26
  • 89
  • 125
20
votes
2 answers

Why does `gmtime` take a pointer?

According to the documentation the struct tm *gmtime(const time_t *timer); is supposed to convert the time_t pointed to by timer to a broken down time. Now is there a reason why they decided to make the function take a pointer to the time_t instead…
skyking
  • 13,817
  • 1
  • 35
  • 57
20
votes
1 answer

PaxHeaders in tarball

I'm doing a tar like in C, and I've got a problem. I just want to archive and unarchive files and diretories, so I operate this command: tar -cvf NAME.tar FILE1 [FILE2...] Now I'm trying to get the header POSIX of this archive : struct…
Liroo Pierre
  • 875
  • 2
  • 9
  • 25
20
votes
3 answers

popen equivalent in c++

Is their any C popen() equivalent in C++ ?
Arif
  • 978
  • 12
  • 29
20
votes
6 answers

Correct use of Stat on C

Why does this work : char *fd = "myfile.txt"; struct stat buf; stat(fd, &buf); int size = buf.st_size; printf("%d",size); But this does not work: char *fd = "myfile.txt"; struct stat *buf; stat(fd, buf); int size =…
necronet
  • 209
  • 1
  • 2
  • 3
20
votes
1 answer

Why does mmap() use MAP_FAILED instead of NULL?

Does anybody know why mmap() returns MAP_FAILED instead of NULL? It seems that MAP_FAILED is (void*)-1 on most systems. Why doesn't mmap() just use NULL instead? I know that address 0x0 is technically a valid memory page, whereas (void*)-1 will…
fieldtensor
  • 3,972
  • 4
  • 27
  • 43
20
votes
6 answers

Good collection of libraries for C?

I'm looking for a good collection of libraries for ANSI-C, stuff for handling vectors, hash maps, binary tress, string processing, etc.
thr
  • 19,160
  • 23
  • 93
  • 130
20
votes
4 answers

Exclusively open a device file in Linux

What ways are there available, for exclusively opening a device file (say, the display frame buffer)? [Info: I already know about flock() & friends, which have an effect only when the other applications are also using it (in other words: open() will…
user2075654
  • 201
  • 2
  • 4
20
votes
3 answers

Example of realpath function in C

I'm looking for an example of how to use the realpath function in a C program. I can't seem to find one on the web or in any of my C programming books.
Ralph
  • 6,249
  • 7
  • 23
  • 19
20
votes
2 answers

UNIX / Linux / Mac OSX get permission of file as number

This must be really simple to do but have completely drawn a blank. I can see the permission of files by using ls -la which can give something like: -rwxr-xr-x 1 james staff 68 8 Feb 13:33 basic.sh* -rw-r--r-- 1 james staff 68 8 Feb…
AJP
  • 26,547
  • 23
  • 88
  • 127
20
votes
1 answer

what's the meaning of 'I' in S_IRUSR

S_IRUSR is a macro constant in sys/stat.h of posix. it stands for user read permission bit. the prefix S_ may stand for 'status of' the RUSR maybe Read of User. but what's the meaning of 'I'?
wuhaochi
  • 389
  • 1
  • 3
  • 9