Questions tagged [posix-api]

59 questions
36
votes
5 answers

How can I wait for any/all pthreads to complete?

I just want my main thread to wait for any and all my (p)threads to complete before exiting. The threads come and go a lot for different reasons, and I really don't want to keep track of all of them - I just want to know when they're all…
Brad
  • 11,262
  • 8
  • 55
  • 74
24
votes
1 answer

Is O_NONBLOCK being set a property of the file descriptor or underlying file?

From what I have been reading on The Open Group website on fcntl, open, read, and write, I get the impression that whether O_NONBLOCK is set on a file descriptor, and hence whether non-blocking I/O is used with the descriptor, should be a property…
Daniel Trebbien
  • 38,421
  • 18
  • 121
  • 193
21
votes
5 answers

"fprintf"-like function for file descriptors (i.e. int fd instead of FILE* fp)

Maybe I'm just missing it, but isn't there a function equivalent to fprintf for file descriptors, or even a way to temporarily flip-flop between them?
Will
  • 3,500
  • 4
  • 30
  • 38
17
votes
7 answers

Do I need an extern "C" block to include standard POSIX C headers?

Do I need an extern "C" {} block to include standard C headers in a C++ program. Only consider standard C headers which do not have counterparts in C++. For example: extern "C" { #include #include }
Martin
  • 9,089
  • 11
  • 52
  • 87
17
votes
3 answers

Where does Microsoft Windows' 7 POSIX implementation currently stand?

Is there a full POSIX implementation available in/for Windows 7 (I'm thinking of Windows Services for UNIX)? Is it available in every version of the OS (it seems not)? How does it add/improve or break on previous MS Windows POSIX…
Shinnok
  • 6,279
  • 6
  • 31
  • 44
13
votes
2 answers

Is O_LARGEFILE needed just to write a large file?

Is the O_LARGEFILE flag needed if all that I want to do is write a large file (O_WRONLY) or append to a large file (O_APPEND | O_WRONLY)? From a thread that I read titled "Cannot write >2gb index file" on the CLucene-dev mailing list, it appears…
Daniel Trebbien
  • 38,421
  • 18
  • 121
  • 193
8
votes
3 answers

Does waitpid yield valid status information for a child process that has already exited?

If I fork a child process, and the child process exits before the parent calls waitpid, then is the exit status information that is set by waitpid still valid? If so, when does it become not valid; i.e., how do I ensure that I can call waitpid on…
Daniel Trebbien
  • 38,421
  • 18
  • 121
  • 193
8
votes
2 answers

SIGKILL signal handling

If a linux process is waiting for I/O (i.e it is in SLEEP state) and a SIGKILL signal is issued against it, upon termination (STOPPED state) will it pass through RUNNING or READY state? In other words, for a process to handle a system interrupt such…
Radu Stoenescu
  • 3,187
  • 9
  • 28
  • 45
7
votes
1 answer

What is timer_t at its base?

Gcc and printf says that timer_t is pointer (on my linux). But what is placed by this pointer, and is NULL a valid timer id? Also, is it platform-specific thing, e. g. it is pointer on linux, int on macOs, sth. else on BSD.
val - disappointed in SE
  • 1,475
  • 3
  • 16
  • 40
7
votes
1 answer

Are parallel calls to send/recv on the same socket valid as per POSIX standard?

I am trying to understand the usage of socket APIs (recv, send, select, close, etc) on parallel threads. That means using one socket file descriptor on two parallel threads. I have gone through this question. But still I am not able to find any…
rashok
  • 12,790
  • 16
  • 88
  • 100
7
votes
1 answer

How do I set the terminal foreground process group for a process I'm running under a pty?

I've written a simple wrapper script for repeating commands when they fail called retry.py. However as I want to see the output of child command I've had to pull some pty tricks. This works OK for programs like rsync but others like scp apply…
stsquad
  • 5,712
  • 3
  • 36
  • 54
7
votes
1 answer

Where is Message queue content stored?

While using the POSIX Message queues I noticed there were some files being created on the File system with the name I was creating the queues. My questions : Q1. Do message queues queue up the messages on the Hard Disk and not RAM ? Q2. If so,…
Amit Tomar
  • 4,800
  • 6
  • 50
  • 83
6
votes
0 answers

Get reference count value (counter value of file using) for file by descriptor?

In Linux, is it possible to get the reference count value (counter value of using a file) for a specified file by descriptor by using non-kernel API?
ramb0tn1k
  • 151
  • 1
  • 9
5
votes
1 answer

POSIX seekdir() and telldir() behaviour after target folder modification

consider the following task : 1) read a target directory contents, pass each found dirent structure to some filter function and remember filtered elements somehow for the later processing 2) some time later, iterate through the filtered elements…
konstantin
  • 69
  • 1
  • 4
4
votes
1 answer

Grouping while using regexec

I have an input string like 051916.000. I would like to segregate 05, 19, 16 and 000. I am trying to use regexec in this way in C language. regex_t r; regmatch_t pmatch[4]; char* pattern = "/([0-9]{2})([0-9]{2})([0-9]{2})\\.(.*)"; int status =…
Gaara
  • 695
  • 3
  • 8
  • 23
1
2 3 4