posix

Where are all my inodes being used?

How do I find out which directories are responsible for chewing up all my inodes? Ultimately the root directory will be responsible for the largest number of inodes, so I'm not sure exactly what sort of answer I want.. Basically, I'm running out of available inodes and need to find a unneeded directory to cull. Thanks, and sorry for t...

Is it possible to avoid a wakeup-waiting race using only POSIX semaphores? Is it benign?

I'd like to use POSIX semaphores to manage atomic get and put from a file representing a queue. I want the flexibility of having something named in the filesystem, so that completely unrelated processes can share a queue. I think this plan rules out pthreads. The named posix semaphores are great for putting something in the filesystem...

Differences between System V and Posix semaphores.

What are the trade-offs between using a System V and a Posix semaphore? ...

Subversion creating revision directories with too-strict permissions

This morning, I tried to commit a revision to Subversion and found that all of a sudden I did not have permission to do so. Can't move '/svn/db/txn-protorevs/21000-ga9.rev' to '/svn/db/revs/21/21001': Permission Denied Looking at the revs directory, I noticed that somebody had committed the 21000th revision, and the group write permiss...

Mixing File Handles and Sockets in Winsock

I'm porting some code from BSD sockets to Winsock, and I'm not sure how to handle the case below. My original application runs a select on both stdin and the network socket: FD_SET(sock, &fd); FD_SET(0, &fd); ... if (select(..., &fd, ... )...) Trying to run this in Winsock gives an error 10038 (WSAENOTSOCK), which makes sense, since ...

Using POSIX message queues instead of TCP sockets - how to establish "connection"?

I have client and server programs which now communicate via TCP. I'm trying out using POSIX message queues instead (in cases where the client and server are on the same machine, of course). My hope is that it will improve performance (specifically via reduced latency). I've worked out most of it, but am not sure about one thing: how t...

Help with basic threading concept / race conditions

I'm learning about POSIX threads right now, but I guess this is just a general question on multithreading, so I hope that anyone can help me. I have this example from the book that I am working on which demonstrates a race condition: void *thread_main(void *thread_number) { printf("In thread number %d.\n", *(int *)thread_number); } ...

Accessing half-duplex serial port with POSIX

I'm asked to read from and write to a half-duplex serial connection using POSIX calls (more specifically, writing in C on Linux 2.6.x). I'm having slight troubles finding detailed information on that particular model (most pages concentrate on full-duplex) and as I am getting slight anomalies when reading, I wanted to check whether maybe...

Can I ignore a SIGFPE resulting from division by zero?

I have a program which deliberately performs a divide by zero (and stores the result in a volatile variable) in order to halt in certain circumstances. However, I'd like to be able to disable this halting, without changing the macro that performs the division by zero. Is there any way to ignore it? I've tried using #include <signal.h>...

What size should I allow for strerror_r?

The OpenGroup POSIX.1-2001 defines strerror_r, as does The Linux Standard Base Core Specification 3.1. But I can find no reference to the maximum size that could be reasonably expected for an error message. I expected some define somewhere that I could put in my code but there is none that I can find. The code must be thread safe. Whic...

What is the effect of changing system time on sleeping threads?

If you take a look at the clock_gettime() function, which is available in all BSDs and is actually defined as part of the POSIX standard, you see that there is support for at least three types of clocks (many systems support more than these clocks, but actually the POSIX standard only demands one to be present, all others are optional): ...

pthread_join - multiple threads waiting

Hi, Using POSIX threads & C++, I have an "Insert operation" which can only be done safely one at a time. If I have multiple threads waiting to insert using pthread_join then spawning a new thread when it finishes. Will they all receive the "thread complete" signal at once and spawn multiple inserts or is it safe to assume that the thr...

Converting to Multi-Threaded Socket Application

As I am currently doing this project in only C, I've up untill this point only used my webserver as a single threaded application. However, I dont want that anymore! So I have the following code that handles my Work. void BeginListen() { CreateSocket(); BindSocket(); ListenOnSocket(); while ( 1 ) ...

POSIX cancellation points

Can anyone point me towards a definitive list of POSIX cancellation points? I was just about to answer a question on stackoverflow and realised I didn't know my stuff well enough! In particular, are accept() and select() cancellation points? I have an old book that says no, but I've seen sites on the internet claim that they are. Con...

C/C++ environment initialization

A co-worker just asked me if it was safe to use getenv() in static initializers, that is, before main(). I looked in Stevens, and in the Posix Programmer's Guide, and the best I can find is An array of strings called the enviroment is made available when the process begins. This array is pointed to by the external variable environ,...

Find out if pipe's read end is currently blocking

I'm trying to find out if a child process is waiting for user input (without parsing its output). Is it possible, in C on Unix, to determine if a pipe's read end currently has a read() call blocking? ...

What is the equivalent to Posix popen() in the Win32 API?

Is there a rough equivalent to the Linux/Unix stdio.h popen() function in the Win32 API? If so, where can I find it? Edit: I need to know this to patch an omission in the D standard library. Any answer must use only standard Win32 API, no MSVC-specific functions. Also, I'd prefer something that's not horribly low-level, if it exists...

Is there a listing of the POSIX API / functions?

I'm trying to find out where I can find documentation on POSIX functions, but coming up short. Any recommendations? EDIT: I asked this because we're strictly limited to POSIX compliant functions for this assignment. ...

Detecting that log file has been deleted or truncated on POSIX systems?

Suppose a long-running process writes to a log file. Suppose that log file is kept open indefinitely. Suppose that a careless system administrator deletes that log file. Can the program detect that this has happened? Is it safe to assume that fstat() will report a link count of zero for a deleted file? Truncation, it seems to me, is...

How do I get the size of a directory in C?

Is there a POSIX function that will give me the size of a directory (including all sub-folders), roughly equivalent to "du -s somepath"? ...