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
4361
votes
35 answers

How do I check if a directory exists or not in a Bash shell script?

What command checks if a directory exists or not within a Bash shell script?
Grundlefleck
  • 124,925
  • 25
  • 94
  • 111
1989
votes
19 answers

Why should text files end with a newline?

I assume everyone here is familiar with the adage that all text files should end with a newline. I've known of this "rule" for years but I've always wondered — why?
Will Robertson
  • 62,540
  • 32
  • 99
  • 117
1254
votes
16 answers

How to echo shell commands as they are executed

In a shell script, how do I echo all shell commands called and expand any variable names? For example, given the following line: ls $DIRNAME I would like the script to run the command and display the following ls /full/path/to/some/dir The purpose…
Jack Nock
  • 14,703
  • 5
  • 22
  • 18
1072
votes
15 answers

What is the meaning of "POSIX"?

What is POSIX? I have read the Wikipedia article and I read it every time I encounter the term. The fact is that I never really understood what it is. Can anyone please explain it to me by explaining "the need for POSIX" too?
claws
  • 52,236
  • 58
  • 146
  • 195
836
votes
14 answers

How to kill all processes with a given partial name?

I want to kill all processes that I get by: ps aux | grep my_pattern How to do it? This does not work: pkill my_pattern
Łukasz Lew
  • 48,526
  • 41
  • 139
  • 208
587
votes
12 answers

How do I execute a command and get the output of the command within C++ using POSIX?

I am looking for a way to get the output of a command when it is run from within a C++ program. I have looked at using the system() function, but that will just execute a command. Here's an example of what I'm looking for: std::string result =…
Misha M
  • 10,979
  • 17
  • 53
  • 65
408
votes
10 answers

What is /dev/null 2>&1?

I found this piece of code in /etc/cron.daily/apf #!/bin/bash /etc/apf/apf -f >> /dev/null 2>&1 /etc/apf/apf -s >> /dev/null 2>&1 It's flushing and reloading the firewall. I don't understand the >> /dev/null 2>&1 part. What is the…
resting
  • 16,287
  • 16
  • 59
  • 90
347
votes
6 answers

When should I use mmap for file access?

POSIX environments provide at least two ways of accessing files. There's the standard system calls open(), read(), write(), and friends, but there's also the option of using mmap() to map the file into virtual memory. When is it preferable to use…
Peter Burns
  • 44,401
  • 7
  • 38
  • 56
264
votes
4 answers

Suppress echo of command invocation in makefile?

I wrote a program for an assignment which is supposed to print its output to stdout. The assignment spec requires the creation of a Makefile which when invoked as make run > outputFile should run the program and write the output to a file, which has…
noobler
  • 3,495
  • 4
  • 22
  • 26
259
votes
9 answers

What is the Difference Between read() and recv() , and Between send() and write()?

What is the difference between read() and recv(), and between send() and write() in socket programming in terms of performances, speed and other behaviors?
Sajad Bahmani
  • 17,325
  • 27
  • 86
  • 108
211
votes
3 answers

How can I convert a file pointer ( FILE* fp ) to a file descriptor (int fd)?

I have a FILE *, returned by a call to fopen(). I need to get a file descriptor from it, to make calls like fsync(fd) on it. What's the function to get a file descriptor from a file pointer?
Phil Miller
  • 36,389
  • 13
  • 67
  • 90
201
votes
5 answers

What does "#define _GNU_SOURCE" imply?

Today I had to use the basename() function, and the man 3 basename (here) gave me some strange message: Notes There are two different versions of basename() - the POSIX version described above, and the GNU version, which one gets after #define…
Gui13
  • 12,993
  • 17
  • 57
  • 104
182
votes
4 answers

Difference between Real User ID, Effective User ID and Saved User ID

I am already aware of the real user id. It is the unique number for a user in the system. On my system, my uid is $ echo $UID 1014 $ What do the other two IDs stands for? And what is the use of effective user id and saved user id and where do we…
mohangraj
  • 9,842
  • 19
  • 59
  • 94
170
votes
4 answers

C++ error: undefined reference to 'clock_gettime' and 'clock_settime'

I am pretty new to Ubuntu, but I can't seem to get this to work. It works fine on my school computers and I don't know what I am not doing. I have checked usr/include and time.h is there just fine. Here is the code: #include #include…
naspinski
  • 34,020
  • 36
  • 111
  • 167
164
votes
9 answers

What is the difference between sigaction and signal?

I was about to add an extra signal handler to an app we have here and I noticed that the author had used sigaction() to set up the other signal handlers. I was going to use signal(). To follow convention I should use sigaction() but if I was writing…
Matthew Smith
  • 6,165
  • 6
  • 34
  • 35
1
2 3
99 100