linux

Simulating file descriptor in user space

I would like to implement a socket-like object in user space. There's an important requirement that it should be pollable (i.e. it's state should be queryable via select or poll call). Is there a platform neutral way of implementing such an object? I'm aware that on Linux there's eventfd which kind of suits the needs except that there'...

How to know if a process had been started but crashed in Linux

Consider the following situation: - I am using Linux. I have doubt that my application has crashed. I had not enabled core dump. There is no information in the log. How can I be sure that, after the system restart my app was started, but now it is not running, because it has crashed. My app is configured as a service, written in C/C++....

settop box hacking

I've recently bought a new set-top box, and the hacker spirit beckons me to carry out things with it.. i understand there could be no standard procedure to hack it / play with it still there should so my questions are : what hardware knowledge do i need to have inorder to get a basic understanding on how a set-top box works. (any how...

How can I edit the $PATH on linux ?

Hi, I am using ubuntu 9.04 I need to add some folder to my $PATH. I know how to read the path: echo $PATH I want to be able to edit it and add 2 other paths. Thanks ...

in place editing using awk

I want to add a line at top of file say f1 using awk Is there a better way than : awk 'BEGIN{print "word"};{print $0}' f1 > aux;cp aux f1;\rm aux does awk has something like -i option in sed. ...

How can I drop privileges in Perl?

I created a server program that will be started as root. After it is started I want to drop privileges to another user. How can I do this securely? ...

Approaches and recommendations for multiple OS user authentication techniques

I’m looking for recommendations of how to authenticate user/password combination and verify group association across a number of differing operating systems. Basically I have a C# application that is working in both MS Visual Studio C# and Mono C# and I need to add an authentication mechanism to it to support Windows, Linux, and MacOSX....

How can I make Perl wait for child processes started in the background with system()?

I have some Perl code that executes a shell script for multiple parameters, to simplify, I'll just assume that I have code that looks like this: for $p (@a){ system("/path/to/file.sh $p&"); } I'd like to do some more things after that, but I can't find a way to wait for all the child processes to finish before continuing. Conver...

Detecting the output stream type of a shell script

I'm writing a shell script that uses ANSI color characters on the command line. Example: example.sh #!/bin/tcsh printf "\033[31m Success Color is awesome!\033[0m" My problem is when doing: $ ./example.sh > out or $./example.sh | grep The ASCII codes will be sent out raw along with the text, mucking up the output and just gener...

Does malloc lazily create the backing pages for an allocation on Linux (and other platforms)?

On Linux if I were to malloc(1024 * 1024 * 1024), what does malloc actually do? I'm sure it assigns a virtual address to the allocation (by walking the free list and creating a new mapping if necessary), but does it actually create 1 GiB worth of swap pages? Or does it mprotect the address range and create the pages when you actually to...

Is it normal for "rsyslogd" to cost 170M memory?

One of my sites runs extremely slow, and I use top command to see that "rsyslogd" cost 170M memory, is that normal? If not,how can I limit the size of memory "rsyslogd" cost,or the frequency the "rsyslogd" runs? ...

Remote proxy with shared memory in C++

Suppose I have a daemon that is sharing it's internal state to various applications via shared memory. Processes can send IPC messages to the daemon on a named pipe to perform various operations. In this scenario, I would like to create a C++ wrapper class for clients that acts as a kind of "Remote Proxy" to hide some of the gory detai...

How to find size of static allocations from binary?

Is it possible to determine the total amount of memory dedicated to static and global variables from the binary? I'm looking for a Linux utility that reads an elf file and figures out how much memory is pre-allocated for variables. ...

Eclipse cross-compile... how can I do that?

Hi, I am developing on a Windows machine using Eclipse in C code. All the files are physically located on a Linux server. I am using Eclipse only for editing and code browsing. When I want to compile, I open a terminal and telnet to the Linux server from which I call a file that sets up few variables and eventually invoke a "make" comm...

Shred: Doesn't work on Journaled FS?

Shred documentation says shred is "not guaranteed to be effective" (See bottom). So if I shred a document on my Ext3 filesystem or on a Raid, what happens? Do I shred part of the file? Does it sometimes shred the whole thing and sometimes not? Can it shred other stuff? Does it only shred the file header? Thanks, Dan CAUTION: Not...

Whats the most popular Linux distro for a USB flash drive?

I want to put Linux on a USB flash drive in order to run some extension to Pure Data that aren't support for Windows. Is there a particular distro that everyone is using for Linux on a flash drive? ...

NTFS (Direct) Reader for Linux

I managed to damage my NTFS partition pretty well (Details*; I don't think its extremely relevant but it might be.) and was wondering if there is any linux tool that can read an invalidly partitioned harddrive. In particular, Active@ NTFS Reader does exactly what I need; it seems to trust less of what the file system is telling it and fr...

how to evaluate a given path within a bash shell

Hi all, Is there a bash command that takes as input a file path and returns an absolute file path? More specifically I would like a command that takes as input a path such as: /tmp/yaneeve/kit/linux/../../output/kit/SOURCES//usr//apps/myapp/lib and returns the path: /tmp/yaneeve/output/kit/SOURCES/usr/apps/myapp/lib Thanks! ...

Learning Kernel Programming

Guys, I want to learn linux kernel programming. What would be the starting points for that ? What could be some of the simpler problems to target ? thanks in advance ...

Linux/C++ How to debug release application

Hello, I have linux c++ multithreaded application. Now it's tested on production servers and have segfault. Problem is that I cannot reproduce that error on any of my test servers and have no access to production servers. I have no dump or any other useful information. Only line: segfault at 0000000046bf0fb8 rip 000000000048ac6b rsp 0000...