linux

pthread with callback to python VM

Let's say I have a python script which loads a shared library (SL) through ctypes. The SL sets up a pthread T1 The python script configures callbacks through the SL i.e. python script calls functions from the SL with references to python callables Now, let's say T1 calls a "callback" function, are the following assumptions true: ...

How can I find out the device name and the OBEX interfaces from a USB device?

Hello! In a shell-script (or Perl) I need a subroutine that returns for all my USB devices, their device names, and, if available, their respective OBEX interfaces. I managed to get the device names and - with obexftp --usb - the obex-interfaces. How can I find out which device belongs to an OBEX interface number? ...

how to use setuid() from root to become user, with the possiblity of becoming root again later ?

Hello all, I'm trying to do the safe thing, and have a program that needs to runs as root to drop its privileges when it doesn't need them. This works well if I chmod my binary with the SUID bit, and make it belong to root, as now I have UID = some user, and EUID = root, so I can use seteuid(0) and seteuid(getuid()) to respectively rais...

Advantages of using JNA over native process execution

I have a project that currently executes many native binaries using java.lang.Process. Assuming that their functionality is available in native library form - what would be the advantages of executing said library functions using JNA instead? The process executions are fairly heavy - they take a few seconds to complete. Am I correct in...

programatically disable hardware prefetching on AMD systems

is there a way to programatically disable the hardware prefetcher on an AMD system like you can in an Intel system as discussed in this topic Specifically for the AMD Opteron Barcelona or Istanbul architecture. ...

What's the advantage of queues over pipes when communicating between processes?

What would be the advantage(s) (if any) of using 2 Queues over a Pipe to communicate between processes? I am planning on using the multiprocessing python module. ...

Which IDE for C++ software can I use for targeting Windows, Linux and OSX?

Hello I was reading today question on IDEs fo C++, and there are very good ones like Netbeans. My question is about creating a software in C++ on Windows Environment, but let users install and run my software also on Linux and OSX. Does netbeans has a compiler to do the job, or is there any good IDE which has a compiler for targeting...

create emacs alias that starts in background?

Hi, I have an alias in bash that runs emacsclient if emacs daemon is already running and start emacs otherwise. However, in the event that a fresh instance of emacs is fired up, can I make it run in the background so I can still use that terminal (or close it)? In my bash profile, I have alias ec="/usr/bin/emacsclient.emacs-snapshot -n ...

C++ figure out CPU/Memory usage

I have a C++ app called ./blah (to which I have the source code) when I run ./blah I can run "top" and see how much memory & cpu "./blah" is using. Now, is there anyway for "./blah" to access that information itself? I.e. when I run ./blah, I want it to every second dump out it's CPU & Memory usage. What library should I be using to d...

Moving from windows programming to Linux Programming

I'm moving from windows programming (By windows programming I mean using Windows API) to Linux Programming. For programming Windows, the option we have is Win32API (MFC is just a C++ wrapper for the same). I want to know if there is something like Linux API (equivalent to WINAPI) that is exposed directly to the programmer? Where can I...

Resource management by Linux

When a program with some theards, mutexes, shared data, file handles crash because of too much memory allocation, which all resources are freed. How do you recover? ...

Simple, fast SQL queries for flat files.

Does anyone know of any tools to provide simple, fast queries of flat files using a SQL-like declarative query language? I'd rather not pay the overhead of loading the file into a DB since the input data is typically thrown out almost immediately after the query is run. Consider the data file, "animals.txt": dog 15 cat 20 dog 10 cat 3...

does linux kill command terminate child processes?

When you invoke "kill" on a parent process, are the child processes subsequently killed as well? ...

Any alternatives to this awk script to soothen subversion pain ?

On my development server, I run svn updates to deploy bug fixes or changes to the webapp's code. Normally I run: svn stat --show-updates and then selectively chose which files to update; appending the selected files to the end of a svn update command. I miss GIT's command line interface and as a concession, I just want to improve the...

FlashChartHelper for OpenFlashChart2 in CakePHP: blank charts

So I have recently started playing with Ubuntu, PHP, and CakePHP and have been pretty happy with the LAMP stack. Except now I'm trying to build a simple web page that can display collected data in a graph. Apparently OpenFlashChart2 with the FlashChartHelper plugin is pretty good, but I cannot get it to actually display a graph. I got...

database connection in php with MS Access on linux hosting

Hi I am running on php. And in my local I am working on windows environment so it was easy to connect to MS Access Database using ODBC connector. But on my live server environment there is Linux so there is a problem regarding the DB connection. So what are the steps to connect to MS Access DB in Linux environment using php. Thanks...

How do you save the cursor attributes without saving position with escape sequence?

printf '\e[s' will save the attributes and position of the cursor, so that the script can reset them using printf '\e[u'. But I only want to save the attributes. In other words, I want to change the color of text, print some text, and then restore the color settings at the end of the script. If I use the [s and [u sequences, I will be...

Per-thread locale in linux

Is it possible to specify per-thread in Linux? ...

Gettext without process locale

I want to use gettext for i18n. But I need to translate messeges to a different languages. Is it possible to specify a locale for a one gettext call? ...

Use ini file in c on Linux

Is there any standard way of reading a kind of configuration like ini files for linux using c? I am working on a Linux based hand held and writing code in c. Otherwise, I shall like to know about any alternatives. ...