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

Listing only folders in directory

I want to list folders in a directory in C++, ideally in a portable (working in the major Operating Systems) way. I tried using POSIX, and it works correctly, but how can i identify whether the found item is a folder?
m4tx
  • 4,139
  • 5
  • 37
  • 61
25
votes
4 answers

Is there something to replace the functions?

The user thread functions in are deprecated because they use a deprecated C feature (they use a function declaration with empty parentheses for an argument). Is there a standard replacement for them? I don't feel full-fledged threads…
zneak
  • 134,922
  • 42
  • 253
  • 328
25
votes
6 answers

Can write(2) return 0 bytes written*, and what to do if it does?

I'd like to implement a proper write(2) loop that takes a buffer and keeps calling write until the entire buffer is written. I guess the basic approach is something like: /** write len bytes of buf to fd, returns 0 on success */ int write_fully(int…
BeeOnRope
  • 60,350
  • 16
  • 207
  • 386
25
votes
3 answers

how to install posix in php

POSIX does not appear when I run php -m cmd, however, I see it from the phpinfo() –enable-posix=shared on Linux with Plesk 9. Basically, I can't use posix_*() functions as described at http://www.php.net/manual/en/ref.posix.php this shows doesn't…
Nizzy
  • 1,879
  • 3
  • 21
  • 33
25
votes
5 answers

why pthread causes a memory leak

Whenever I create a pthread, valgrind outputs a memory leak, For example the below code: #include #include #include void *timer1_function (void *eit){ (void) eit; printf("hello world\n"); …
Johan Elmander
  • 646
  • 2
  • 8
  • 11
25
votes
6 answers

POSIX sh equivalent for Bash’s printf %q

Suppose I have a #!/bin/sh script which can take a variety of positional parameters, some of which may include spaces, either/both kinds of quotes, etc. I want to iterate "$@" and for each argument either process it immediately somehow, or save it…
Jesse Glick
  • 24,539
  • 10
  • 90
  • 112
24
votes
4 answers

Linux MMAP internals

I have several questions regarding the mmap implementation in Linux systems which don't seem to be very much documented: When mapping a file to memory using mmap, how would you handle prefetching the data in such file? I.e. what happens when you…
Mr Jay
24
votes
2 answers

wait(null) and wait(&status) C language and Status

What is the difference between wait(null) and wait(&status) in c system programming? And what is the content of the pointer status ?
user3260388
  • 313
  • 1
  • 4
  • 10
23
votes
6 answers

Is wget or similar programs always available on POSIX systems?

Is there an HTTP client like wget/lynx/GET that is distributed by default in POSIX or *nix operating systems that could be used for maximum portability? I know most systems have wget or lynx installed, but I seem to remember installing some Ubuntu…
drew010
  • 68,777
  • 11
  • 134
  • 162
23
votes
5 answers

Is it always safe to convert an integer value to void* and back again in POSIX?

This question is almost a duplicate of some others I've found, but this specifically concerns POSIX, and a very common example in pthreads that I've encountered several times. I'm mostly concerned with the current state of affairs (i.e., C99 and…
Quantumboredom
  • 1,426
  • 11
  • 19
23
votes
4 answers

libc source location - for download or online viewing?

Sorry I know this is stupid but where is linux libc source code available? What I downloaded from GNU didn't seem to be what I wanted, specifically I could find nothing in the pthreads function family. Is there an online (hypertexted…
ValenceElectron
  • 2,678
  • 6
  • 26
  • 27
23
votes
7 answers

Return value range of the main function

What does standard say about main return values range? Say only up to 255? Because int main(void){ return 256; } echo $? ; # out 0
Nyan
  • 2,360
  • 3
  • 25
  • 38
23
votes
2 answers

Setting process name on Mac OS X at runtime

I'm trying to change my process' name as it appears in ps and Activity Monitor at runtime. I found several notes that there is no portable way to do this (which I don't care about). Here's what I tried. None of these approaches worked for…
Marco Masser
  • 1,076
  • 1
  • 8
  • 14
23
votes
5 answers

PThread vs boost::thread?

Having no experience with threading in the past, which threading technique in C++ will be the easiest for a beginner? boost::thread or pthreads?
Chris
  • 21,549
  • 25
  • 71
  • 99
23
votes
3 answers

Signal handling and sigemptyset()

Could anyone please explain in a really easy way to understand what sigemptyset() does? Why is it useful? I've read a bunch of definitions but i just don't understand. From what i gather it tracks the signals that are being used for blocking…
user2644819
  • 1,787
  • 7
  • 28
  • 41