linux

how can a function return two values.

We know that a c function never returns more than one value.Then how come the fork() function returns two values? How it is implemented? ...

Playing an mp3-file with libsox

Hi all, I have an application in which I need to play an mp3 file. What I'm looking for is some kind of wrapper functions for libsox (or any other audio lib). I have been looking all over the net but have not found any option that is fast to implement. I'm looking for something like; bla=open_file("/mnt/music/my_music.mp3") play_thefil...

How to run script commands from variables?

I tried to run commands using pipes. Basic: single="ls -l" $single which works as expected Pipes: multi="ls -l | grep e" $multi ls: |: No such file or directory ls: grep: No such file or directory ls: e: No such file or directory ...no surprise bash < $multi $multi: ambiguous redirect next try bash $multi /bin/ls: /bin/ls: c...

2d geometry drawing tool

I'm looking for some tool/library that is able to draw simple 2d geometries from text file or programatically. I already found List of interactive geometry software but that not quite what I'm looking for. I would prefer something more similar in usage to graphviz or gnuplot. I already wrote some scripts for gnuplot but this tool has bee...

Extract 1 file from tar.gz with bash

Is it possible to programmatically pull a single file from a decently sized .tar.gz without extracting the entire tarball to disk? Essentially I need to get inside large tar.gz files over the network and extract 1 small text file. It seems somewhat over-the-top to pull and extract the tarball to disk, then pull the file out, then delete...

postfix configuration to receive emails

Hi guys, I have a requirement to accept all incoming emails into our server and process them through a script. I will need some pointers as to what should be the required configuration. This is the current main.cf :- myorigin = /etc/mailname smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu) biff = no # appending ...

How to call php script from C code on Linux

Hi, just wanted to know how to call php script from running C code on Linux and pass a couple of parameters. Thanks ...

gdb problem setting hardware watchpoint/how to set software watchpoint

An earlier question explained that on x86 the size of objects being watched is limited by debug registers. here. As expected, I can "watch" a double variable. But I can't watch a double datamember, eg watch pObject->dPrice produces Hardware watchpoint 1: pObject->dPrice But when you try to continue execution, it says Could not in...

how to read absolute positions of tap from Cirque touchpad in linux

we have one of Cirque touchpads. http://www.cirque.com/downloads/docs/tsm9925.pdf now we want to read absolute position of tap from this touchpad using c\c++ application. unfortunately company developed only windows drivers but we need to read positions in the linux. we tried to use /dev/input/eventN subsystem but received only directi...

eclipse helios fails to find g++, gdb, $PATH, make

I am using eclipse CDT but it fails to find any of the linux toolchain like make, g++, gdb. seems like it is failing to retrieve $PATH.Could you let me know how can I fix this? ...

Creating a window manager for Linux

I want to create a simple stacking window manager (in C) for private use, mainly for the purpose of learning and challenging myself. I've looked through twm's source code which has relatively few bells and whistles but it seems very low level since it's not based on a widget toolkit.[1] Would using a toolkit such as GTK+ be preferable? ...

What is the lowest possible process ID that a Linux process can have?

On my system the lowest ID running right now is 1 (init). I'm making a small wrapper function around pidof and I was wondering, what is the lowest possible process ID a process can have? The reason I ask is because I would like to return an integer from my function indicating "process was not running" (pidof itself returns an empty stri...

How to pass parameters in function that not limit the number of parameters ?

It come across to me that function like printf() have not limited the number of parameters. But when debugging program on Solaris, I noticed it will push at most 5 parameters into stack, common register will be used if there are more than 5 parameters. So what will happen if even common register is not enough in function like printf ?...

Sandboxing applications on CentOS 5 as non-root

Classic problem: I'd like to be able to run unsafe applications in a sandboxed environment on my CentOS Server 5.5 server, as a non-root user. chroot would be ideal for this, but it's not able to be started by a non-root user. And a lot of the sandboxing solutions I've found online are for Debian-based distros. Any suggestions? ...

How to set up a cron job to run an executable every hour?

I need to set up a cron job that runs an executable compiled using gcc once every hour. I logged in as root and typed crontab -e Then I entered the following and saved the file. 0 * * * * /path_to_executable However, the cron job does not work. I see that when I type /...path_to_executable I get a segmentation fault. I can only ex...

Making sense of "/dev/video" ouput.

I've tried writing a simple application thats supposed to detect pixel differences from the /dev/video device. Like motion does. I don't know how the /dev/video device works, so most of it was guesswork. What I found is that it seems like the data ( from the specific webcam ) can be divided into sections of 8192 bytes. I assume each rep...

Run C program on windows written in Linux

I have c project which is written in linux. It runs on linux very well. But now I want to run it on windows. I want to know best and easy ways to run it on windows. ...

ssh session logging

I observed (CentOS) that the SSH sessions are getting logged with respective file names in the folder /var/log/sessions/ Is it a default behaviour? If no, how to enable it? ...

socket descriptor vs file descriptor

Hi, read(2) and write(2) works both on socket descriptor as well as on file descriptor. In case of file descriptor, User file descriptor table->file table and finally to inode table where it checks for the file type(regular file/char/block), and reads accordingly. In case of char spl file, it gets the function pointers based on the maj...

Creating a cross platform installer in Linux

Hi How to create installer of say file which is swf and html and this html has to be created a short cut on the linux desktop . Is there any software that will solve my problem. Thanks ...