posix

POSIX AIO Library and Callback Handlers

According to the documentation on aio_read/write, there are basically 2 ways that the AIO library can inform your application that an async file I/O operation has completed. Either 1) you can use a signal, 2) you can use a callback function I think that callback functions are vastly preferable to signals, and would probably be much eas...

How Operating System callbacks work.

Follow up question to: This question As described in the linked question, we have an API that uses an event look that polls select() to handle user defined callbacks. I have a class using this like such: class example{ public: example(){ Timer* theTimer1 = Timer::Event::create(timeInterval,&example::FunctionName); ...

Adding support of Windows to POSIX project... How painful? Is it worth the effort?

Hello, I'm trying/thinking of making CppCMS - C++ Web Framework project little bit more cross platform. Today I can easily support Linux, OpenSolaris, FreeBSD and even Cygwin. But when it comes to Native Windows it becomes really painful: The overview of the situation: I'm POSIX/Linux developer and I'm barely familiar with Native Win...

Limiting Singleton instance to thread.

What is a good way to implement a singleton that will be restricted only to the thread that seeks its instance? Is there a thread id or something that I can use to do that? I'm using Carbon threading API but will have to implement this on windows and pure POSIX later too, so any technique is appreciated. ...

Should flags in POSIX-style operating systems be prefixed by "no" or "no_"?

When you have a boolean option and a flag for setting it to false by prefixing "no" to the name, should it be "no" or "no_"? What's most commonly used or better style? For example: --no_foo or --nofoo ...

Should command line options in POSIX-style operating systems be underscore style?

Should the name of command line options for a program in a POSIX-style operating system be underscore-style, like --cure_world_hunger or maybe some other style? --cureworldhunger --cure-world-hunger --cureWorldHunger What's most common? What's better style? What's more Bash-friendly (if such a thing exist)? ...

Interprocess communication Posix

Hi all, I am working on a debian system and have to communicate some processes so i am looking for some advise or documentation ... As an imposed rule, i cannot use any library such as boost, so i am trying to choose between systemV IPC and POSIX ipc facilities , but i have not found any good document about the later. ¿Could you please...

Does the POSIX module in the standard Perl distribution work in Win32/64?

I was wondering whether using POSIX.pm would make my Perl code less cross platform. From reading the documentation it's not very clear how well it's supported on Win32/64 Perl implementations. Is it wise to rely use POSIX.pm if one cares about portable code? ...

Realistically, what pthreads functionality is generally used?

Hi, I'm working on the POSIX subsystem of my operating system project, and I've reached the point where I would like to work on pthreads support. However, I'm not certain about the extent to which I should implement them. What is the most-used pthreads functionality? Is there anything I could safely "just stub out" for now and implemen...

Is there and equivalent for Microsoft's UuidCompare, UuidCreate, etc in Linux or POSIX environment?

Is there an equivalent for Microsoft's UuidCompare, UuidCreate, etc in Linux or POSIX environment? ...

Concatenate path and basename

basename(3) and dirname(3) can split an absolute path into its respective components. Short of using snprintf(3), is there a natural posix-compliant library call that does the inverse - takes a directory and a filename and concatenates them? Manually concatenation works fine for me, but can get a little tedious at times. ...

what is linux analog to WIN32_FIND_DATA structure

also, how would you build that structure from scratch. What is the fastest way to get the source code of the ls command in linux? Thanks. ...

pthread_cond_wait doesn't unlock mutex on os x

I can't find any evidence online of pthread_cond_wait being strange on Mac OS X, but it seems to be failing the simplest test for me. The function int pthread_cond_wait(pthread_cond_t *, pthread_mutex_t * ); is supposed to unlock the mutex argument #2 and then wait for a signal to be sent on the condition argument #1. I wrote a simpl...

Best way to atomically create files

Hi SO, The 'best practice' (as I see it) to atomically create a new file, is to open a temporary file (using tmpfile()), and then moving the file to it's final location. However, this won't work well if the temporary file is on a different mountpoint, as this will result in the file gradually building up and additionally result in unne...

getutent and Linux timer issues

I have a problem running the below code , which invokes getutent() to count the total number of users currently logged in to the system. The timer will be invoked every 1sec and will set the boolean named "isSigAlrmOccured" to true and exit.The main function checks whether the timer signal is delivered by checking this boolen and monitor...

Why does start_routine for pthread_create return void* and take void*

The function header for pthread_create looks like this: int pthread_create(pthread_t * thread, const pthread_attr_t * attr, void * (*start_routine)(void *), void *arg); I understand it all except that the function pointer for start_routine is of the form void* (fpointer) (void...

Multi-process synchronization - better choice than semaphores?

I've got a queue resource that is shared across multiple producers and multiple consumers. All are independent processes; no one process "owns" the queue. By nature of the implementation access to the queue must be controlled and only one process must be allowed to push or pop at any given moment. I figured using a POSIX named semapho...

SUS/POSIX shell-compliant replacement of '-nt' test

I'm working on porting bash script to SUS/POSIX-compliant shells. I was able to remove most of bashisms myself but I'm currently stuck with last one. The script is for generating crontab based on files in cron.d directory, and it uses '-nt' test to check whether any of input files has changed since last time the crontab was generated. ...

How can I determine whether a POSIX app. is running within 5 minutes of system boot?

From a C++ app. compiled for AIX, HP-UX, Linux, OSX and Solaris is there a simple way to determine whether the app. is running within 5 minutes of system boot? On Windows I can do this: // return true if OS has recently booted up bool at_os_boot_time() { /* GetTickCount() returns the number of miliseconds since system start. ...

Dealing with time-periods such as 5 minutes and 30 seconds in R

Hi, Is there a good way to deal with time periods such as 05:30 (5 minutes, 30 seconds) in R? Alternatively what's the fastest way to convert it into an integer with just seconds? I can only convert to dates and can't really find a data type for time. I'm using R with zoo. Thanks a lot ! Seconds was the best way to deal with thi...