Все вопросы: [posix]

161 вопросов

похожие теги: posix-apiposix-selectposix-ere
5
голосов
1ответов
634 просмотров

Perl: Blocking signal NOT delayed as it should be -> Test code provided

In a Perl script I'm writing I'm having a problem where I block the INT and QUIT signals, execute a process within backticks, and then unblock the INT and QUIT signals. I want to prevent an INT or a QUIT from reaching the child process and killing it. The script successfully blocks and unblock...

2
голосов
4ответов
2672 просмотров

Do threads clean-up after themselves in Win32/MFC and POSIX?

I am working on a multithreaded program using C++ and Boost. I am using a helper thread to eagerly initialize a resource asynchronously. If I detach the thread and all references to the thread go out of scope, have I leaked any resources? Or does the thread clean-up after itself (i.e. it's stack ...

5
голосов
1ответов
760 просмотров

Portable way to achieve ls' -v flag (i.e. sort by version)?

I'm working on a some build scripts that I'd like to depend on only standardized features. I need to sort some files by version. Say the files are bar-1.{0,2,3} bar-11.{0,2,3}. By default, ls gives me: bar-1_0 bar-11_0 bar-11_2 bar-11_3 bar-1_2 bar-1_3 Getting what I want is easy using 'ls -...

25
голосов
4ответов
21728 просмотров

Setting thread priority in Linux with Boost

The Boost Libraries don't seem to have a device for setting a thread's priority. Would this be the best code to use on Linux or is there a better method? boost::thread myThread( MyFunction() ); struct sched_param param; param.sched_priority = 90; pthread_attr_setschedparam( myThread.native_hand...

2
голосов
3ответов
6030 просмотров

What is better for a message queue? mutex & cond or mutex&semaphore?

I am implementing a C++ message queue based on a std::queue. As I need popers to wait on an empty queue I was considering using mutex for mutual exclusion and cond for suspending threads on empty queue, as glib does with the gasyncqueue. However it looks to me that a mutex&semaphore would d...

0
голосов
1ответов
942 просмотров

SSL_accept hangs after calling fork()

I'm writing an app in C++ using openssl, and I can't seem to get the ssl socket connection to work. I have an abstract class, with multiple functions implemented using various protocols by the inheriting classes and simple TCP and UDP ( posix sockets ) work fine. I could not get the ssl workin...

2
голосов
3ответов
341 просмотров

expected behavior of posix extended regex: (()|abc)xyz

On my OS X 10.5.8 machine, using the regcomp and regexec C functions to match the extended regex "(()|abc)xyz", I find a match for the string "abcxyz" but only from offset 3 to offset 6. My expectation was that the entire string would be matched and that I would see a submatch for the initial "a...

3
голосов
5ответов
2588 просмотров

Mystery pthread problem with fork()

I have a program which: has a main thread (1) which starts a server thread (2) and another (4). the server thread (2) does an accept(), then creates a new thread (3) to handle the connection. At some point, thread (4) does a fork/exec to run another program which should connect to the socket...

1
голосов
1ответов
1434 просмотров

Is there a Unicode equivalent for `{\pGraph}` in Java / POSIX regular expressions?

According to the documentation of java.util.Pattern, the POSIX character class \p{Graph} ([:graph:] in POSIX notation) matches "a visible character: [\p{Alnum}\p{Punct}]". However, this is limited to ASCII characters only. Is there an equivalent class or expression for matching (visible) Unicode ...

4
голосов
2ответов
6464 просмотров

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

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 ! Seco...

2
голосов
3ответов
335 просмотров

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 numbe...

2
голосов
1ответов
195 просмотров

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 si...

4
голосов
1ответов
2750 просмотров

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 mome...

28
голосов
2ответов
11819 просмотров

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_rou...

2
голосов
2ответов
960 просмотров

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 del...

7
голосов
7ответов
16420 просмотров

How do I wake select() on a socket close?

I am currently using select loop to manage sockets in a proxy. One of the requirements of this proxy is that if the proxy sends a message to the outside server and does not get a response in a certain time, the proxy should close that socket and try to connect to a secondary server. The closing...

1
голосов
4ответов
344 просмотров

Best way to atomically create files

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 ...

4
голосов
1ответов
2386 просмотров

pthread_cond_wait doesn't unlock mutex

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 ...

0
голосов
2ответов
1178 просмотров

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.

4
голосов
1ответов
2862 просмотров

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...

0
голосов
1ответов
1113 просмотров

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?

5
голосов
2ответов
239 просмотров

Realistically, what pthreads functionality is generally used?

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...

1
голосов
1ответов
218 просмотров

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?

0
голосов
4ответов
3282 просмотров

Interprocess communication Posix

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 a...

29
голосов
3ответов
4225 просмотров

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 suc...

0
голосов
1ответов
108 просмотров

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

1
голосов
6ответов
1212 просмотров

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 appr...

5
голосов
5ответов
1581 просмотров

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

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 ...

2
голосов
2ответов
1304 просмотров

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(...

6
голосов
4ответов
4714 просмотров

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 ...