linux

Protecting /etc/passwd and /etc/shadow from concurrent access

How do I protect /etc/passwd and /etc/shadow from concurrent access? I don't see any locking mechanism in pwd.h. I see the manual for pwd_mkdb mentions obtaining a lock, but is it just locking the file for exclusive access? Is there a convention for locking these files if I were to write a utility to modify them directly, or through t...

How can I view log files in Linux and apply custom filers while viewing?

I need to read through some gigantic log files on a Linux system. There's a lot of clutter in the logs. At the moment I'm doing something like this: cat logfile.txt | grep -v "IgnoreThis\|IgnoreThat" | less But it's cumbersome -- every time I want to add another filter, I need to quit less and edit the command line. Some of the fil...

Converting a script/program into an installable tarball?

I am quite familiar with writing small programs or scripts, and I am also familiar with downloading a source tarball and installing it using ./configure && make && make install (or, failing that, doing whatever the INSTALL or README files tell me to do). However, I don't know how to take a script that I've written and package it up (alon...

music visualization error with gstreamer

hi I am trying to visualize a music file in gstreamer using the following command: gst-launch filesrc location=file.mp3 ! decodebin ! audioconvert ! tee name=myT myT. ! queue ! autoaudiosink myT. ! queue ! goom ! colorspace ! autovideosink But I get this error : "There may be a timestamping problem, or this computer is too slow." P...

Creating a Cron Job - Linux / Python

Hi I have a Django script that I need to run, I think the commands could be called through bash. Thing is the script causes memory leaks after a long a period of time, so I would like to create an external cron job which calls the Python script. So the script would terminate and restart while retaking the lost memory. Can someone po...

linux shell scripting kiddie's question

an Unix shell script with only purpose - count the number of running processes of qmail (could be anything else). Easy thing, but there must be some bug in code: #!/bin/bash rows=`ps aux | grep qmail | wc -l` echo $rows Because echo $rows always shows greater number of rows (11) than if I just count rows in ps aux | grep qmail T...

ELF oddities and dynamic linking in ARM linux

There are things in ARM elf binaries I'd like to understand better. I need to figure this out get my homebrew assembler output ELF executables for gp2x f200. So I started by compiling this program with open2x cross-compiling toolchain: #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(){ chdir("/usr/gp2x"); ex...

How to get the absolute path for a given relative path programmatically in Linux?

How to get the absolute path for a given relative path programmatically in Linux? Incase of Windows we have the _fullpath() API. In other words, I mean what is analogous API to _fullpath of Windows in Linux? ...

Loading C++ shared library through Java process on linux giving errors

(Developer environment: CentOS 4.7, KDevelop 3.1.1, gcc 3.4.6) I created a c++ shared library and a test executable that uses this shared library. Things work fine. But when I load this library through Java ie Java calls JNI which in turn loads this shared library, there is an error which states "* glibc detected * free(): invalid next...

using make command infix to postfix conversion

this is my 1.c content #include "2.h" #include<stdio.h> #include<string.h> void push(int ele) { stack[tos]=ele; tos++; } char pop() { tos--; return(stack[tos]); } void show() { int x=tos; printf("--The Stack elements are....."); while(x!=0) printf("%c, ",stack[--x]); } //Function to get the pr...

Valgrind output showing addresses not code against errors

I am running Valgrind on my program. It shows me two errors but mentions only addresses against them and not actual code even on a debug build. Could you pls. help me understand what it says and how to reach the erroneous line of code? The output is ==23002== Memcheck, a memory error detector. ==23002== Copyright (C) 2002-2005, and GN...

C or C++ for Linux/UNIX daemon programming?

Dear stackoverflow, The topic basically says it all. I want to go more into writing daemons for Linux/UNIX systems and I want things to be fast and stable. Everything I look at seems to be written in C, however, some new projects seem to be using C++ a bit more. So if I were to start my own project, let's say a modular HTTP daemon, whi...

svgalib : cant see anything

Hello, I had compiled some examples from svgalib, the console show : Using EGA driver svglib 1.4.3 Nothing more, its like its drawing somewhere but I cannot see it. This could be a ver very noob question about svgalib, but also a configuration problem. Also I check the virtual console that it says is drawing (if I run from X), runni...

C - Reading multiple files

Hi everyone, just had a general question about how to approach a certain problem I'm facing. I'm fairly new to C so bear with me here. Say I have a folder with 1000+ text files, the files are not named in any kind of numbered order, but they are alphabetical. For my problem I have files of stock data, each file is named after the comp...

Does linux kernel reference count kernel objects?

If 2 file descriptors were dupped to the same file (i.e. 506 and STDOUT), will invoking close(506) cleanup the object associated by both and render STDOUT unusable? Or does kernel implement reference counting for its files? ...

Determining which signal interrupted my system call (Linux)

After my system call has returned because it was interrupted by a signal, is there a way to determine exactly which signal type (i.e. child process termination) caused the interruption? ...

Help me create JojoMips algorithm, the BogoMips for Java VMs

Hello there, I would like to test the speed of different Java platforms and thought about creating a JojoMips benchmark routine that would work like the Linux BogoMips. It would do a calculation and would provide a number like: 4346 JojoMips. The faster the virtual machine, the higher the JojoMips. I thought counting how many decimals o...

J2EE consultants: What free OS do you prefer to implement for clients?

I am aiming to develop J2EE web apps for clients, and am wondering what OSS operating systems you all have had the best luck with? Windows is expensive, RHEL, SUSE Enterprise Linux, and Solaris are free to implement but have support options; BSDs are good servers but not much on the paid support side if the client wishes to have that ki...

Linux Kernel - what function holds the source where port numbers are randomly chosen?

Anyone know what function or file in linux holds the algorithm that finds a random port to use for the bind() system call? I'm hunting all over and cannot find the method that contains this algorithm in the Linux source. Thanks! ...

good text-based powerful java IDE that runs on linux

The problem is - I like old goods ;) Having some old laptop which I just LOVE. It runs Xorg of course, and it's fast. But Intellij IDEA is still slow. Thought about emacs, but never used. Isn't emacs too complicated? Going to work in text mode under X in many windows and make some scripts to automate things. ...