linux

Compiling a shared library with Qt on Ubuntu 9.10

I am new to both Qt and Linux C++ development (although I have many years C and C++ development experience on Windows). I have some legacy C projects (source files and headers - [not using Qt]) that I want to compile into shared libs on Linux. I am proposing to store my projects under the following structure: /home/username/Projects/p...

How to determine return address on stack ?

I know that if I am inside some fuction foo() which is called somewhere from bar() function, then this return address is pushed on stack. #include <stdio.h> void foo() { unsigned int x; printf("inside foo %x \n", &x ); } int main() { foo(); printf("in main\n")...

How do I determine if a pthread is alive?

How do I determine if a detached pthread is still alive ? I have a communication channel with the thread (a uni-directional queue pointing outwards from the thread) but what happens if the thread dies without a gasp? Should I resign myself to using process signals or can I probe for thread liveliness somehow? ...

Is there a way to determine if free() would fail?

Is there a way to determine if free() would fail if ever called on a certain memory block pointer? I have the following situation: a thread having access to a shared resource fails whilst it may have been in the state of freeing the said resource. Now I need to devise a safe way to clean-up this shared resource. Of course I have assig...

Variable Corruption in bash script

Given the following code I am expecting the variable $NewFile to be /var/ftp/pub/faxes/myfile.txt.pdf However my system is returning: ".pdf/ftp/pub/faxes/myfile.txt" $Ext returns: "txt" $oFileName returns: "/var/ftp/pub/faxes/myfile.txt" I have tried this a hundred different ways with no luck. PDF=".pdf" #extract the file.ext from t...

Undefined symbols. ld: symbol not found

Everything is working except this undefined symbols error: bash-3.2$ make g++ -Wall -g solvePlanningProblem.o Position.o AStarNode.o PRM.o PRMNode.o Worl.o SingleCircleWorld.o Myworld.o RECTANGLE.o CIRCLE.o -o solvePlanningProblem `Undefined symbols: "Obstacle::~Obstacle()", referenced from: Myworld::~Myworld()in Myworld.o ...

How to Create a Telnet Interface for an Application

I have come across a couple of proprietary applications on Linux platform which are administered via telnet. Remote telnet is not enabled but on the host you do a telnet session. You get an interface where you enter commands to make the application work. I was wondering how a telnet interface is built for any particular application. Not ...

Is there any way to determine the available stack space at run time?

I know that stack size is fixed. So we can not store large objects on stack and we shift to dynamic allocations (e.g. malloc). Also, stack gets used when there is nesting of function calls so we avoid recursive functions as well for this reason. Is there any way at runtime to determine how much stack memory is used so far and how much is...

Atomic file save on Linux without losing metadata

I'm working on a Perl-based file synchronization tool. It downloads files into a temporary directory (which is guaranteed to be on the same filesystem as the real file) and then moves the temporary files into place over the old ones, preserving metadata like permissions, ownership, and ACLs. I'm wondering how to achieve that last step ...

Is `errno` thread-safe?

In errno.h, this variable is declared as extern int errno; so my question is, is it safe to check errno value after some calls or use perror() in multi-threaded code. Is this a thread safe variable? If not, then whats the alternative ? I am using linux with gcc on x86 architecture. ...

How many open udp or tcp/ip connections can a linux machine have?

There are limits imposed by available memory, bandwidth, CPU, and of course, the network connectivity. But those can often be scaled vertically. Are there any other limiting factors on linux? Can they be overcome without kernel modifications? I suspect that, if nothing else, the limiting factor would become the gigabit ethernet. But for ...

Environment variable used in shell script appear blank in log file when run by cron

Forgive my ignorance, but I am somewhat new to shell scripting and the use of environment variables in Linux. I have a script that performs a backup of a MySQL database. I have the following lines in the script that are used to log a successful dump of the database: output=`date; echo "Database export successful from $ENV_HOSTNAME to ...

Thread-safe, lock-free increment function?

UPDATED: Is there a thread-safe, lock-free and available on all Linux distros increment function available in C or C++ ? ...

viewing source of namespace resolver functions linux fedora

I want to see the source of functions like ns_initparse(), res_search() etc. Where can I look for them? ...

testing to see how many instances of ruby script i can run

is it true that it is better to run multiple instances of ruby scripts than doing multiple threads for ruby < 1.9 ? I would like some tools or approaches to measure how much bandwith, cpu, memory is being used by each instances of ruby script (ex. a web spider). The goal here is trying to see the maximum number of ruby scripts that ca...

Help with C program(gcc) in Linux

Hi... I have a project for my college but unfortunately, I struggle in programming, apart from simple C programs. Anyway, the way I see it, I think the code I need should be around 20-30 lines, so if somebody can provide me some help I'll be really grateful. Here is the project: A parent process will produce 10 random integer numbers (...

How detect programatically count of bytes allocated by process on Heap ?

How detect programmatically count of bytes allocated by process on Heap ? This test should work from process itself. ...

Difference between "system" and "exec" in Linux?

What is the difference between system and exec family commands? Especially i want to know which one of them creates child process to work? ...

multicast ip address - blocked in call to recvfrom

i am writing a simple multicast application. i intend to run it on localhost. i have done the following: char *maddr; . . . sendfd = socket(...); struct sockaddr_in sasend; sasend.sin_family = AF_INET; sasend.sin_port = htonl(portno); inet_ntop(maddr, &(sasend.sin_addr.s_addr)); struct sockaddr_in sarecv; memcpy(&sarecv, &sasend); ...

sed stream editor unix linux command : how to keep retain a paragraph with a particular text string

Hi I have managed to put text in a file by separating them by blank lines. I am trying to keep only those paragraphs that have a particular string. Though the Sed FAQ mentions a solution it does not work (see examples below) http://www.catonmat.net/blog/sed-one-liners-explained-part-two/ 58. Print a paragraph that contains “AAA”. (P...