linux

Why would Linux reuse a file descriptor allocated by pipe()

I'm seeing an issue using both sockets and pipes in Linux. Specifically, we call pipe(), which allocates the next two available file descriptors... let's say 10 and 11. Then we call accept() on a socket, expecting it to allocate 12. Instead, it allocates 11. We've tested a bit, and it seems the second FD returned from pipe() is alway...

Atomic Increment & Fetch

Hi, I'm looking for a way to atomically increment a short, and then return that value. I need to do this both in kernel mode and in user mode, so it's in C, under Linux, on Intel 32bit architecture. Unfortunately, due to speed requirements, a mutex lock isn't going to be a good option. Is there any other way to do this? At this point, ...

How can I print to the console in color on Mac OS X in a cross-platform manner?

How can I output colored text using "printf" on both Mac OS X and Linux? ...

Why is RLIMIT_STACK lost after fork or exec on linux?

Hello: On linux, it is said that rlimit of a process is kept intact after either fork or exec. But I lose my RLIMIT_STACK in the child either after fork or after exec. Would someone please give some explain? Here is some descriptive output of my program. //The parent has an RLIMIT_STACK like this RLIMIT_STACK, soft - 10485760, hard - ...

C code on Linux under gdb runs differently if run standalone?

Hello, I have built a plain C code on Linux (Fedora) using code-sorcery tool-chain. This is for ARM Cortex-A8 target. This code is running on a Cortex A8 board, running embedded Linux. When I run this code for some test case, which does dynamic memory allocation (malloc) for some large size (10MB), it crashes after some time giving err...

Books for understanding linux kernel?

To aid with poking around + running the linux kernel under qemu / UML; what are good books that describe how the linux kernel work? ...

Monitor a process

Is there a way I a process can be monitor and if it were to die, can a script be called which in turn will bring the process back up ? ...

How to find size of heap present in Linux?

Hello, I have a Linux running on a ARM Cortex-A8 processor board. The version of the kernel is obtained by (uname -a): Linux 2.6.29-dirty #2 Fri Jan 29 16:54:21 IST 2010 armv7l unknown To debug some of my application which crashes due to malloc() failure(The size i am mallocing is large), and the board has 208 MB DRAM. On this Linux/b...

I need help with this ogre dependent header (Qgears)

I'm 2 errors away from compiling Qgears. (Hacked Version of the Final Fantasy VII Engine) I've messed with the preprocessors to load the actual location of the ogre header files. Here are the errors: ||=== qgears, Debug ===| /home/cj/Desktop/qgears/trunk/project/linux/src/core/TextManager.h|48|error: invalid use of ‘::’| /home/cj/Desk...

Running Python With STDIN From Bash

I have a bash code (Mybash1.sh) where the result I need to pass to another bash code (Mybash2.sh) that contain Python Here are the codes. Mybash1.sh #! /bin/bash # Mybash1.sh cut -f1,3 input_file.txt | sort | ./Mybash2.sh Mybash2.sh is this: #! /bin/bash #Mybash2.sh python mycode.py foo.txt <("$@") > output.txt # do something for...

web-browser based GUI

I am working on an application in Linux which will interfaces with hardware. One of the requirements is to create the GUI in Web-browser . the application will be c++ based. I m not familiar with web realted stuff so i want to know Is it possible to do such a thing (currently it's a console application take input from txt file/cmd line)....

Universal construct for STDIN and Fileinput in Python Code

I want my code to be able to accept input from a file AND stdin. What's the construct to do it? I mean a unifying construct that implies file1 = sys.stdin and file1 = fileinput.input(sys.argv[1]) ...

Problems running a C program on Debian

Hello, I have a following problem: I compiled my application on Linux Ubuntu 9.10 using CodeBlocks. It is a C program (which uses few libraries, like libmysql, jasper...) I copied the compiled program to a remote system running Debian 2.6.18, chmodded +x the application but when calling ./my_app bash still says "No such file or director...

What is the best way to share common logic between identical template-driven websites?

I've built a white label website in PHP that uses templates. Each white label will have it's own set of templates and possibly a few extra folders. All the white label sites are on the same LAMP server. What I would like to do is keep one centralised copy of the main code on the server and then have every site point to these files. Then...

Is it possible to set up a gcc cross compiler on Linux to compile 64 bit targets on a 32 bit architecture?

Hi, I know you can compile to a 32 bit target on 64 bit Linux by using the -m32 flag, but is it also possible to compile to 64 bit on a 32 bit machine by using the -m64 flag? Or alternatively, do you need to set up a cross gcc tool chain that supports 64 bit targets and is this possible on a 32 bit machine? Regards, Johan ...

How to work around inter-repository single file externals not supported by SVN 1.6?

I'm using SVN externals to include a couple of directories from another repository but I also need to set up externals for two individual files in the root of the project directory. According to the documentation this is not yet possible: The URL for a file external must be in the same repository as the URL that the file external ...

How to check file encoding in Linux? Handling multilingual scripts.

Hello Guys, My company has php scripts with texts in different languages (including french, german, spanish, italian and english). Developers decided to use Latin-1 encoding as base for everyone, so this way nobody will override file encoding and corrupt foreign languages in it. (At first some developers used html entities, but this w...

Is there any difference between IPv4 and IPv6 at the socket level ?

I need to add IPv6 support to an existing socket-based application which currently only supports IPv4. To embrace the incoming era of IPv6, someone ordered me to add an IPv6 interface for the app and let the outside world to choose either the IPv4 interface or the IPv6 interface when trying to communicate with the app. My question is: i...

Posting to internal socket fails when firewall is enabled

I'm working on an application where two processes communicate over loopback interface. Its Linux based system. I'm encountering a very strange problem, when Firewall is enabled, send to internal socket is failing. If I add an iptables rule (in output chain) as shown below from command prompt everything works fine. iptables -I OUTPUT ...

Your PHP MySQL library version differs from your MySQL server version

I've recently upgraded MySQL on my Debian 5.0.4 server to 5.1. Now phpMyAdmin shows the following warning: Your PHP MySQL library version 5.0.51a differs from your MySQL server version 5.1.43 Is it likely to cause any problems? ...