Skip to content
Advertisement

Is there an invalid pthread_t id?

I would like to call pthread_join for a given thread id, but only if that thread has been started. The safe solution might be to add a variable to track which thread where started or not. However, I wonder if checking pthread_t variables is possible, something like the following code. Where some_invalid_value could be 0, or an implementation dependant ‘PTHREAD_INVALID_ID’

bash scripting: how to find the absolute path of “symlink/..”?

Given two files: Upon calling parent/scripts/hello.sh from any location, I would like (in the script) to find the full path of the parent directory. In this case parent. The main issue is that parent/scripts/.. refers to generic in unix. On the other hand, everything involving regexes is not generic and may be error prone. Solutions that don’t work: All these

Is it possible to set pthread CPU affinity in OS X?

In Linux there is a sched_setaffinity() function defined in sched.h, but I can’t seem to find anything like that in Mac OS X 10.6 pthreads implementation… If it is not possible to set affinity, what is the default policy in OS X? Answer Mac OS X has Thread Affinity API and you can use it with pthread ID as thread_policy_set(pthread_mach_thread_np(pthreadId),

Change process name in Linux

I’m on Linux and I am forking/execing a new process out of my C spawn application. Is it possible to also change the naming of these new child processes? I want to be able to identify the process being started in case something goes wrong and I need to kill it manually. Currently they all have the same name. Answer

clear scrollback buffer of Linux Virtual Console Terminals

I’d like to clear the scrollback buffer on Linux console VTs programmatically. i.e. not just clear the current visible screen, but the entire scrollback buffer, too. I.e. everything that after a clear screen would still be visible with Alt-PgUp should be gone too. Anybody got an idea how to achieve that in nice code? Answer I don’t think this is

How to get formatted date time in python

I want my Linux Filename like this How can i get the date variable formatted like above in Python IN bash i write Answer You can use the same formatting string in strftime on a datetime object: Incidentally, I’d just like to put a word in for the joy of ISO-8601 date formatting

Advertisement