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
3
votes
1 answer

fseek only working with fread call after rather than read?

I open a file: FILE *fp = fopen("hello_world.txt", "rb"); which just has the contents Hello World! Then I get the size and reset to the beginning: fseek(fp, 0L, SEEK_END); size_t sz = ftell(fp); fseek(fp, 0L, SEEK_SET); When I go to perform a…
rb612
  • 5,280
  • 3
  • 30
  • 68
3
votes
3 answers

How to use POSIX select()

Shoud I make file descriptors non-blocking before using them in select()?
Mihran Hovsepyan
  • 10,810
  • 14
  • 61
  • 111
3
votes
4 answers

How to find a file on the $PATH in Bash?

The utility which will find a program on the path but what about an arbitrary data file? I must be searching for the wrong stuff but I can't find any way to do this with a standard utility so I thought of writing a little Bash script to do it. The…
Neil C. Obremski
  • 18,696
  • 24
  • 83
  • 112
3
votes
2 answers

flock() vs. fcntl() semantics in glibc

Related: one, two It's stated that flock() (BSD-locks) and fcntl() (POSIX record-level locks) gives the user incompatible semantics, particularly, in regards of lock release. However, in glibc flock() is implemented in terms of POSIX fcntl(). (I…
DimG
  • 1,641
  • 1
  • 16
  • 23
3
votes
2 answers

How write posix waitpid() analog for windows?

I want to port my linux code to windows. I don't want use cygwin or mingw. I would like to do this via WinApi. So who can help me to write waitpid() analog under windows?
Mihran Hovsepyan
  • 10,810
  • 14
  • 61
  • 111
3
votes
0 answers

Posix way to open socket descriptor in shell

In bash, we can use file descriptors in order to (try to) open socket descriptors, as follow: exec 3<>/dev/prot/host/port where: prot can be tcp or udp; host can be a valid hostname or Internet address; port can be an integer port number or…
ingroxd
  • 995
  • 1
  • 12
  • 28
3
votes
0 answers

aio_write() and lio_listio() of POSIX AIO don't work correctly in write operation

I'm setting up a asynchronized writer and want operation order on file be guaranteed by that. I use it as writer in another program which read a pcap file. Consider I have already tried to use both linux-aio and POSIX aio in my code seperately, to…
Resist
  • 73
  • 6
3
votes
1 answer

How to properly replace sprintf_s by sprintf in C++03?

sprintf_sis a Microsoft implementation of the function sprintf where they patched a flaw, adding an argument to take a boundary value where the function is limited to write. An equivalent was introduced in C++11: snprintf. But here, we are talking…
Sandburg
  • 757
  • 15
  • 28
3
votes
2 answers

POSIX alternative to multiple variables assignments with read

In bash (works on v4 at least), the following commands allow to assign multiple variables from a string : IFS=',' read a b <<< "s1,s2" IFS=',' read a b < <(echo "s1,s2") # an equivalent After one of these commands : $ echo $a s1 $ echo $b s2 But…
norbjd
  • 10,166
  • 4
  • 45
  • 80
3
votes
2 answers

Can drand48() ever return 1?

The manual of drand48() says: The drand48() and erand48() functions return non-negative, double-precision, floating-point values, uniformly distributed over the interval [0.0 , 1.0]. (source) So just for clarification: Does this mean that 1.0…
Andreas
  • 9,245
  • 9
  • 49
  • 97
3
votes
1 answer

readline hangs on manual pipe()

I'm trying to dispel the magic fork variant of open: # magic-fork.pl if (open my $fh, '-|') { # fork self, make new fd for reading, attach child STDOUT to it STDOUT->say('parent getpid: ', $$); STDOUT->say('parent STDOUT->fileno: ',…
daxim
  • 39,270
  • 4
  • 65
  • 132
3
votes
2 answers

How to safely pass an arbitrary text as parameter to a program in a shell script?

I'm writing a GUI application for character recognition that uses Tesseract. I want to allow the user to specify a custom shell command to be executed with /bin/sh -c when the text is ready. The problem is the recognized text can contain literally…
danpla
  • 655
  • 5
  • 9
3
votes
2 answers

Replacing all characters in a regular expression match with another character?

I'm doing analysis on a file and I want to mask some characters (while retaining their original byte count) before moving this file down the pipeline. For example, given file.txt: Hello there Cory Klein Have fun Hello there Samantha Rodgers Writing…
Cory Klein
  • 51,188
  • 43
  • 183
  • 243
3
votes
3 answers

Executing another program from C++ with specified running timeout

I'm writing a program (A genetic algorithm implementation) which executes another program using "system" method to calculate fitness. The problem is that another program sometimes hangs for unlimited amount of time. How can I execute a program with…
Sergej Andrejev
  • 9,091
  • 11
  • 71
  • 108
3
votes
1 answer

Convert POSIX pattern to PCRE in php (eregi to preg_match)

eregi(" \"\']+)[\"\']?[[:space:]]+name=[\"\']?(form_page_origine|form_origine|page_origine)[\"\']?[[:space:]]*/?>" How can I switch it to preg_match? thank.
Sophy SEM
  • 223
  • 5
  • 19
1 2 3
99
100