linux

A error about "Address 0x0 is not stack'd, malloc'd or (recently) free'd" in c program under linux enviroment

[Edit1:] For the seqName, I declare it as a global parameter at the beginning of the file as char seqName[20]; [Edit2:] Aren't those number of passing to the program during the actual execution? I got the following message just by using the valgrind tool. The command I input is: jl@ubuntu:~/work/dsr_analysis$ valgrind --tool=memchec...

Possible memory leak problem

I write two pieces of c programs like following, during memcheck process using Valgrind, a lot of mem leak information is given. int GetMemory(int framewidth, int frameheight, int SR/*, int blocksize*//*,int ALL_REF_NUM*/) { //int i,j; int memory_size = 0; //int refnum = ALL_REF_NUM; int input_search_...

How to determine the event of the linux devices?

Hi, I am learning some embedded programming. I am using Linux as my platform and I want to create a daemon program that will check if a particular device(magstrife, keypad, etc) is active. Like for example, my daemon program is running in the background, then when I make a keypress event, my deamon app will do something. What implem...

mysql_close doesn't kill locked sql requests

I use mysqld Ver 5.1.37-2-log for debian-linux-gnu I perform mysql calls from c++ code with functions mysql_query. The problem occurs when mysql_query execute procedure, procedure locked on locked table, so mysql_query hangs. If send kill signal to application then we can see lock until table is locked. Create the following SQL table ...

Why setupterm terminates the program?

This is sample program from "Beginning Linux Programming" book: #include <stdio.h> #include <term.h> #include <curses.h> #include <stdlib.h> int main() { setupterm("unlisted", fileno(stdout), (int *)0); printf("Done.\n"); exit(0); } Running it, I have this result: ./badterm 'unlisted': unknown terminal type. Accordi...

How can I programmatically find the IP address/netmask/gateway configured for a specific network device in Linux?

Hi I would like to write a piece of code which checks, for each network device (e.g. eth0, lo, master devices) some statistics and configuration data about that device. I could find the statistics data (and most of the configuration data) in /sys/class/net/..., however, I couldn't find any C/C++ API or any entry in procfs/sysfs listing t...

Terminating inetd service

Hi, I have written some simple inetd-Service in C. It reads a string from the user, compares it to another string and then terminates. At least, this is what I want it to do. After reaching the return(0);-statement in main(), it simply restarts and presents me a new prompt. Is there any way to tell inetd that it should terminate the co...

Run command when connected to a specific wireless network

In my university there's a certain wlan network open for the students and employees. To use it, however, one must first log in via a website using your own username and password. This can also be done by submitting a http request with the right POST-data to the same website. I already have a shell script that does this but I'm still curi...

How can I suspend \ resume the video caputre operation in v4l2 ?

Hi, I use the v4l2 api for video capture and image applying image processing algo' on each frame. I wish to be able to suspend the video capture. I see that there are 2 options for ioctling (new verb, its gonna catch) the stream. VIDIOC_STREAMON, VIDIOC_STREAMOFF will start and stop the stream. Is there a way to suspend \ resume it? ...

Fast method call scheduling in Python

Hi all! For some part of my project I need a process-local scheduling system that will allow me to delay method execution on few seconds. I have thousands of “clients” of this system, so using threading.Timer for each delay is a bad idea because I will quickly reach OS thread limit. I've implemented a system that use only one thread for...

Can someone illustrate what's linux device number's minor number exactly for?

The minor number is used by the kernel to determine exactly which device is being referred to. The above explanation is just two abstract, can someone illustrate? ...

Process identifier in the kernel which is portable between linux like versiones

When I use current->pid on ancicent platforms they doesn't support current->pid does *FILE has something equal to pid that ican use ? some we can call it process "key" ? ...

Little mod_rewrite problem

I have a classifieds website. Each classified is linked like this originally: mydomain.com/ad.php?ad_id=Bmw_M3_M_tech_113620829 What RewriteRule should I use to make this link look like: mydomain.com/Bmw_M3_M_tech_113620829 Also, what do I need to add to my .htaccess file? This is what I have so far: Options +FollowSymLinks ...

Linux shared library that uses a shared library undefined symbol

two shared libraries liba.so and libb.so. liba.so uses libb.so. All c files are compiled with -fPIC. Linking uses -shared. When we call dlopen on liba.so it cannot find symbols in libb.so...we get the "undefined symbol" error. We can dlopen libb.so with no errors. We know that liba is finding libb because we don't get a file not fo...

linux - check if program has died

i wrote a program that needs to continuously run. but since im a bad programmer it crashes every so often. is there a way to have another program watch it and restart it when it crashes? ...

How to force inclusion of an object file in a static library when linking into executable?

I have a C++ project that due to its directory structure is set up as a static library A, which is linked into shared library B, which is linked into executable C. (This is a cross-platform project using CMake, so on Windows we get A.lib, B.dll, and C.exe, and on Linux we get libA.a, libB.so, and C.) Library A has an init function (A_i...

Very simple mod_rewrite questions

1- Does mod_rewrite means that if I make this url: domain.com/ad.php?id=8498292 INTO domain.com/8498292 that all links on my website will have to be changed to the later above? example the link: domain.com/ad.php?id=8498292 wont work now, unless I replace it with domain.com/8498292 ? Or will the server know that they are the s...

mysqldump problem with case sensitivity? Win->linux

When i dump a table with uppercase letters using mysqldump it comes out as lower case in my > dump.sql file. I found a report here in 2006, almost 4 years old http://bugs.mysql.com/bug.php?id=19967 A solution here suggest making linux insensitive. I rather not if possible. Whats the easiest way to copy a win32 db into linux? ...

Spawning and waiting for child processes in Python

The relevant part of the code looks like this: pids = [] for size in SIZES: pids.append(os.spawnv(os.P_NOWAIT, RESIZECMD, [RESIZECMD, lotsOfOptions])) # Wait for all spawned imagemagick processes to finish while pids: (pid, status) = os.waitpid(0, 0) if pid: pids.remove(pid) What this should be doing is spawning ...

Autorun a removable device in Linux

I have a removable device setup so it autoruns when plugged into a Windows machine and pops up a message giving the owner's information, so it can be returned if lost. Is there a way to do this in Linux as well? It doesn't need to be complex, it can be an option in a right-click menu, or a splashscreen, or anything. ...