linux

How to signal a buffer full state between posix threads

Hi I have two threads, the main thread 'A' is responsible for message handling between a number of processes. When thread A gets a buffer full message, it should inform thread B and pass a pointer to the buffer which thread B will then process. When thread B has finished it should inform thread A that it has finished. How do I go abo...

Question about a C macro expansion in Linux Kernel code

I generally have ignored using macros while writing in C but I think I know fundamentals about them. While i was reading the source code of list in linux kernel, i saw something like that: #define LIST_HEAD_INIT(name) { &(name), &(name) } #define LIST_HEAD(name) \ struct list_head name = LIST_HEAD_INIT(name) (You can access the re...

Extracting shell script from parameterised Hudson job

I have a parameterised Hudson job, used for some AWS deployment stuff, which in one build step runs certain shell commands. However, that script has become sufficiently complicated that I want to "extract" it from Hudson to a separate script file, so that it can easily be versioned properly. The Hudson job would then simply update from ...

Interacting with system commands using a web dev language

Hi all, First of all, sorry for the vague title. Let me explain. At work we're currently using SunGrid I've been assigned a project to create a web interface wrapper for interacting with the engine. i.e. displaying users jobs, submitting jobs via a nice GUI etc. (most of the sgrid commands output xml which is nice) My question for yo...

Epoll in EPOLLET mode returning 2 EPOLLIN before reading from the socket

The epoll manpage says that a fd registered with EPOLLET(edge triggered) shouldn't notify twice EPOLLIN if no read has been done. So after an EPOLLIN you need to empty the buffer before epoll_wait being able to return a new EPOLLIN on new data. However I'm experiencing problems with this approach as I'm seeing duplicated EPOLLIN event...

how can i use regex to get a certain string of a file

Hi with linux bash shell , how can i use regex to get a certain string of a file by example: for filename *.tgz do "get the certain string of filename (in my case, get 2010.04.12 of file 2010.01.12myfile.tgz)" done or should I turn to perl Merci frank ...

Equivalent of print "-"x20 of perl in Bash or command line

In perl you can simply write print "-" x 20 and you get a line with dashes...but i need the same thing in bash/commandline on linux without perl/(g)awk etc. any ideas? The intention is to use it in the -exec of the find command and i want to prevent using simple echo "---------" ... ...

Determine how much can I write into a filehandle; copying data from one FH to the other.

How to determine if I can write the given number of bytes to a filehandle (socket actually)? (Alternatively, how to "unread" the data I had read from other filehandle?) I want something like: n = how_much_can_I_write(w_handle); n = read(r_handle, buf, n); assert(n==write(w_handle, buf, n)); Both filehandles (r_handle and w_handle) ...

How to get a glyph outline of a true type character on a linux system

Hello, I'm searching for a library to get the outline of a glyph in a true type font on a linux system. We are using Pango and Cairo but unfortunatly I didn't find anything. I'm looking for somethig similar to GlyphTypeface.GetGlyphOutline under .NET Any help or hints are appreciated! Thanks in advance ...

display font with special characters - UTF-8

Hi, i am trying to display characters like £ on a device which runs under linux . it is using utf-8 charset format . when i get to display a string which contains special characters, it displays other characters too . if i print the string on the console it appears ok, but when i parse the string to load each letter font on the screen i...

shell script background

I have script like this : fullscript.sh if [ ! -f /opt/laks/linux-2.6.33.2.tar.bz2 ] then wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.33.2.tar.bz2 tar -xjf linux-2.6.33.2.tar.bz2 fi for i in $(seq 1 500); do touch /tmp/$i.txt done I'm downloading tar file and then decompress i...

Getting error while linking with g++

Hi all, I try to compile and link my application in 2 steps : Compiling: g++ -c -o file1.o file1.cc general_header.h g++ -c -o file2.o file2.cc general_header.h g++ -c -o file3.o file3.cc general_header.h Linking: g++ -o myApp file1.o file2.o file3.o I'm getting a link error as following: file1.o: file not recog...

How to programmatically detect sata drive unplug in SuSE Linux?

Does anyone know of a method I can use to programmatically detect if a SATA hard drive has been unplugged? Our file system is mounted in READ-ONLY mode when we need to detect the removal of the drive. We noticed the other day that we were able to unplug a hard drive and everything continued to run without a hitch until the next time we...

Copy one column over another in a delimited file

For instance, I needed to remove column 25 and replace it with a copy of column 22 in a simple csv file with no embedded delimiters. The best I could come up with was the awkward looking: awk -F, '{ for(x=1;x<25;x++){printf("%s,", $x)};printf("%s,",$22);for(x=26;x<59;x++){printf ("%s,", $x)};print $59}' I would expect something like ...

How can I "interconnect" two sockets in Linux?

There are two connected sockets. How can I interconnect them? Data appeared on the one socket should be written to the other. EOF/FIN should propogate well. If one is half-closed, the other should also be half-closed. int client = get_connected_client_socket(); int proxy = get_connected_proxy_socket(); negotiate_with_proxy(proxy); i...

How to restart Linux from inside a C++ program?

I have a Qt 4 GUI where I need to have a option in a drop-down menu that allows the user to choose to restart the computer. I realize this might seem redunant with the ability to restart the computer in other ways, but the choice needs to stay there. I've tried using system() to call the following: a suid-root shell script a non-suid s...

Fonts in a multi-platform environment

What is the best way to deal with fonts in a multi-platform distributed system? If I want to use a common font across all systems to show to the user, what's the best way to do this. From the little I've been reading each platform looks to have fonts that are of the same family (ie serif, sans-serif) but with different names. CSS look...

Legacy C++ project using Makefile ..moving to Eclipse IDE?

I have a legacy C++ project on Linux which uses the typical: ./configure make make install to build and install. I would really like to build it instead with an IDE like Eclipse. Is this doable? Is there something in Eclipse that can parse the original Makefile(s) and turn it into an Eclipse project? ...

mmap() for large file I/O?

I'm creating a utility in C++ to be run on Linux which can convert videos to a proprietary format. The video frames are very large (up to 16 megapixels), and we need to be able to seek directly to exact frame numbers, so our file format uses libz to compress each frame individually, and append the compressed data onto a file. Once all fr...

Eclipse CDT -- How to map Linux path's to Windows paths?

We have a C-code project written for a Linux environment but we also want the ability to view and edit the code on Eclipse for Windows and have the headers be resolved. The problem we are facing is that a lot of the headers are included with absolute paths in the Linux format such as: #include "/path/to/custom/header.h" What I would l...