linux

Track changes in nfs / sync nfs over multiple datacenters

We have two datacenters, each with a number of Linux servers that share a large EMC-based nfs. The challenge is to keep the two nfs' in sync. For the moment assume that writes will only occur to nfs1, which then has to propagate the changes to nfs2. Periodic generic rsyncs have proved too slow - each rsync takes several hours to comple...

Sending structs through Unix domain sockets

I am using Unix domain sockets to do some interprocess communication in Linux. Upon connection, the client sends a struct using send to the server. This struct contains some information about the client including an identifier string at the end. The server receives the info just find and sends another struct back. The client blocks with ...

Installing rmagick on Ubuntu

Hey all - I'm trying to get RMagick setup on Ubuntu 10.04. Looked here but had no joy. I even compiled and installed ImageMagick from source, but the instructions here still didn't help me when I try to install RMagick using RubyGems. I got this error: carcher@carcher-laptop:~/Code/temp/RMagick-2.13.1$ sudo gem install rmagick Buildin...

Include Linux header file

How could I include a linux header file? I read from the web that the header file is in /usr/include. However, the header file I need is not in that directory; it is in /usr/src/kernels/2.6.32.../include/linux/. I tried to include the file using the full path. However, the file itself includes other header files as well. Hence, the com...

How does POSIX Threads work in linux?

I thought pthread uses clone to spawn one new thread in linux. But if so, all of the threads should have their seperate pid. Otherwise, if they have the same pid, the global variables in the libc seem to be shared. However, as I ran the following program, I got the same pid but the different address of errno. extern errno; void* f(void...

How can I insert text into another application?

To scratch a personal itch, I'm writing something like a cross between a character map and an on-screen keyboard. When the user selects a character, I'd like to insert it into another application, specifically, the application that would next receive focus if my application were closed. Is there any way to do this? Right now, I work arou...

Get a volume label from Java on linux

Is there any way to read volume label in Java program on Linux? I've found sample of doing that at http://www.rgagnon.com/javadetails/java-0455.html It uses FileSystemView class, but it seems working only on Windows. On Linux for /dev/sdb1 it returns sdb1. ...

shell script cut and sed help

I have 2 two files $cat file1.txt field1=value1 field2=value2 field3=value3 :: :: $cat file2.txt something.field1.some otherthing.field2.anything anything.field3.something I need to read file1.txt and check whether file2.txt for fieldN and replace with valueN so that the result will be something.value1.some otherthing...

How to prevent a Linux program from running more than once?

What is the best way to prevent a Linux program/daemon from being executed more than once at a given time? ...

How to use the pidfile library correctly?

I already read the man page of the pidfile function family. But I don't really understand it. What is the correct usage? Is there a more elaborate example available? I think I understand pidfile_open. But when should I call pidfile_write and prdfile_close? From which process? Parent or child? What parameters do I have to pass to those fu...

why ostringstream could not work well in multithreading environment

Maybe something is weird. When I use STL ostringstream class in my multithreading environment I found that the execution time of each thread increased linearly as the thread number increased. I don't know why this happened. I try to check the ostringstream source code but could not find any synchronization code. Are there some synchroniz...

How to figure out the Linux kernel's source code?

There are some books about Linux developing, internals, managers and so on. but I'm thinking about a documentation that Linux developers write when the commit a patch on the kernel. Does something like that exist? I know there is a mailing list for kernel newbies and some stuff like this but I'm not a newbie and I don't want to be kernel...

get all the thread_id created with pthread_created within an process

Hi , If there is any "intelligent" way to get all the threadIDs created using pthread_created within an process, supposing those threads are created in the third party library that does not expose those data. ...

Cross-platform GUI toolkit in C or C++?

I'm looking to write some simple GUI applications in C or C++, and am stuck for choice between the cross-platform toolkits. Keep in mind that I am developing in Ubuntu, preferably without an IDE, and preferably with good cross-platform support. What are the pros and cons of some of these toolkits? Which have you had the best experience ...

Asynchronous, timed function calling in C on Linux?

What is the easiest, most effective way in C on Linux to asynchronously call a function after a certain delay (like JavaScript's setTimeout) or set a repetitive timer call it periodically (similar to setInterval)? Though this question applies to Linux, I hope there is a method that is cross-platform. ...

Migrating to clean cpanel from a hacked server

Hello, I am about to start migrating sites to a clean install of cpanel. I do not have any backup files from the old hacked server but I do have access to the old harddrive. It is mounted on the new server as a drive. I have found articles such as http://linuxstuffs.wordpress.com/2008/08/31/directory-structure-of-cpanel/ and http:...

how do I kill this bash script?

I have written a bash script, A, that is calling another script, B, over 1000 times in a loop. Ctrl+C kills only script B, only one iteration. Script A keeps running and calling script B again. Can I rewrite something in these scripts so that Ctrl+C will kill script A? ...

After deattaching from a Linux screen and reattaching hotkeys aren't working anymore

If often use screen to run multiple scripts at once on my Linux servers. When I deattach from the screen and later reattach I can't use the hotkeys anymore. F.e. when I try to do CTRL + A followed by an N I don't go to the next instance, I simply see what I type in my terminal. How do I make sure that screen listens to my input, even af...

Using wget to mirror a website and everything from the first level of external sites.

I need to mirror a particular website (all the pages under that particular domain) any pages (but not whole sites) that the website links to. I'm confused about the how to do this wget -r --level=inf (or some other variant) will mirror the site. wget -r -H --level=1 will get all the links (from all domains) to the first level. Anyone...

How to correct drive names in Gtk.FileChooserDIalog under Windows?

Hello! I write the simple example with gtk.FileChooserDialog. It works fine, but there is one problem under WIndows: I see '\' in first button instead of real drive names, such as 'C:\', 'D:\' and so on. I explored FileChooserDialog structure and tried to change '\' by real drive name, but it works unstable. Can anybody help me? import ...