I want to subtract 1 day from a POSIX date and end up at the same time around DST.
For example, when I add a day:
> as.POSIXct('2009-03-08 23:00:00.000') + 86400
[1] "2009-03-09 23:00:00 EDT"
But when I go past, it offsets:
> as.POSIXct('2009-03-08 23:00:00.000') - 86400
[1] "2009-03-07 22:00:00 EST"
What's the best way to deal ...
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 characters?
...
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 that thread (2) is listening to. Occasion...
Hi,
This is my first post on stackoverflow. First of all I'd like to say thanks for this site! It has provided many excellent answers to questions I've had in the past few months. I'm still learning C++, coming from vb6. I'm converting an existing program to C++ and here need to manipulate Sybase timestamps. These timestamps contain dat...
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 "abc" part of the string.
When I try the sa...
Hi
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 working though and after some code browsing ...
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 do the job, I think it contains an integer and ...
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 -v':
bar-1_0
bar-1_2
bar-1_3
bar-11_0
bar-...
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 and any other system resources needed for ...
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 unblocks at the right points in the code, however...
I am trying to match a pattern with a case-statement where the pattern is stored inside a variable. Here is a minimal example:
PATTERN="foo|bar|baz|bla"
case "foo" in
${PATTERN})
printf "matched\n"
;;
*)
printf "no match\n"
;;
esac
Unfortunately the "|" seems to be escaped (interestingly "*" or...
I'm looking for an example of how to use the realpath function in a C program. I can't seem to find one on the web or in any of my C programming books.
...
The POSIX standard defines several routines for thread synchronization, based on concepts like mutexes and conditional variables.
my question is now: are these (like e.g. pthreads_cond_init(), pthreads_mutex_init(), pthreads_mutex_lock()... and so on) system calls or just library calls? i know they are included via "pthread.h", but do t...
There are so many possible errors in POSIX environement. Why some of them (write to unconnected socket in particular) get special treatment in form of signals?
...
I do the regular thing:
fork()
execvp(cmd, ) in child
If execvp fails because no cmd is found, how can I notice this error in parent process?
...
I do the usual fork + exec combination:
int sockets [2];
socketpair (AF_LOCAL, SOCK_STREAM, 0, sockets);
int pid = fork ();
if (pid == 0) {
// child
dup2 (sockets[0], STDIN_FILENO);
dup2 (sockets[0], STDOUT_FILENO);
execvp (argv[0], argv);
_exit (123);
}
// parent
close (sockets[0]);
// TODO wait and see if child crashes
I...
I'm looking for a good collection of libraries for ANSI-C, stuff for handling vectors, hash maps, binary tress, string processing, etc.
...
Are these available for iPhone OS?
The Threading Programming Guide mentions these but does not say if they are also relevant on iPhone OS.
...
I wonder what would happen when I create a joinable thread for writing some big data to "disk". Now, the docs say I can do so by using POSIX threads. Nice! But: Another guy at Apple said, that an app has like 5 seconds or so to quit when the user presses the home button. So for my understanding a "real" nondetached thread has the sense t...
struct timeval represents and instant in time with two members, tv_sec (seconds) and tv_usec (microseconds). In this representation, tv_usec is not by itself an absolute time it is a sub second offset off of tv_sec.
struct timespec works the same way except that instead of microseconds it's offset (tv_nsec) is stored in nanosecond units...