linux

va_args and 64 bits

I'm the lead dev for Bitfighter, and am having problems porting the game to 64-bit Linux. This should be a relatively easy and common problem, but it has stumped a number of people and I have been able to find no good information about it. [[ The code compiles in 32-bit with gcc version 4.1.2, and others, and fails with several variant...

Reducing performance variations on Linux

Hi all, I am trying to benchmark a piece of software that runs on an Intel Pentium with Linux on top of it. The problem is, that I get considerable performance variations during consecutive test runs, when using the RDTSC instruction. Runtimes of exactly the same piece of software vary between 5 million and 10 million clock cycles, so i...

Windows and Linux thread priority equivalence

Windows OS defines the following constants as thread priority: THREAD_PRIORITY_IDLE (-15) THREAD_PRIORITY_LOWEST (-2) THREAD_PRIORITY_BELOW_NORMAL (-1) THREAD_PRIORITY_NORMAL (0) THREAD_PRIORITY_ABOVE_NORMAL (1) THREAD_PRIORITY_HIGHEST (2) THREAD_PRIORITY_TIME_CRITICAL (15) And Linux has sched_get_priority_max() and sched_get_priorit...

DNS Apache redirect for domain names held elsewhere

An external company holds the name servers for several domains for a web site which I host. I host the site and have a vhost setup with the domainName and domainAlias for: www.example.com admin.example.com The external domains also need to redirect to the site: www.somedomain.com www.anotherdomain.com What must I add to my vhost...

How can I accept multiple TCP connections in Perl?

I have a problem with Perl script for Linux. It's main purpose is to be middleman between 3 applications. What it should do: It should be able to wait for UDP text (without spaces) on $udp_port When it receives that UDP text it should forward it to the TCP client that is connected Problem is my app currently works until the first t...

What is a good general approach for deciding return values in C?

My program is written in C for Linux, and has many functions with different patterns for return values: 1) one or two return n on success and -1 on failure. 2) some return 0 on success and -1 on failure. 3) some return 1 on success and 0 on failure (I generally spurn using a boolean type). 4) pointers return 0 on failure (I generally sp...

Does gcc, icc, or Microsoft's C/C++ compiler support or know anything about NUMA?

If I have a multi-processor board that has cache-coherent non-uniform memory access ( NUMA ), i.e. separate "northbridges" with separate RAM for each processor, does any compiler know how to automatically spread the data across the different memory systems such that processes working on local threads are mostly retrieving their data from...

How to correctly save the unix top command output into a variable?

I've got to save the output of the top command into a variable and I do this: myvar=`top -b -n1 | head -n 18` The problem is that it seems to be ignoring the return characters, so when I echo the content of $myvar I see something like: top - 15:15:38 up 745 days, 15:08, 5 users, load average: 0.22, 0.27, 0.32 Tasks: 133 total, 1 runn...

Sample source files for Linux Device Drivers, Third Edition

I am working through Linux Device Drivers, Third Edition and while the book is released under Creative Commons Attribution-Share Alike license, I can't seem to locate the source code for the examples used in the book. Some Amazon reviews mention that they do exist, but fail to provide a reference. In the book snippets you can see that ...

In linux, how can I test whether the output of a program is going to a live terminal or to a file?

When you use git it seems to magically know whether standard out is going through a pipe or into a file vs when it is being displayed to the console. For example, if you have colors enabled and you do git status it will colorize the output for different categories of files being listed. However, if you do git status | less or ...

delete all shared memory and semaphores on linux

how can i delete all NOT USED semaphores and shared memory with a single command in ubuntu?? ...

SVG to PDF on a shared linux server

I have a website which uses SVG for an interactive client side thingamabob. I would like to provide the option to download a PDF of the finished output. I can pass the final SVG output back to the server, where I want to convert to PDF, then return it to the client for download. This would need to work on a headless shared linux server,...

howto run a cgi that is compiled as a linux binary on a linux web-host

All, My host supports Perl CGI scripts, how do I use a compiled CGI script on the host? I tried setting execute permissions via chmod, but when I try and run it via the browser, I get a server error. Thanks in advance for all help. ...

call function at specific time intervals in Linux

What is the best way to call a function inside a Linux daemon at specific time intervals, and specific time (e.g. at 12am every day, call this function). I'm not referring to calling a process with crontab, but a function within a long running daemon. Thanks ...

getting dependent modules (shared objects) for a binary

I have a binary file on linux .. tclsh8.4. It depends on certain tcl*.so files. Is there a way to get this information from the binary file itself? The tcl*.so files on which the binary tclsh8.4 depends is in some other directory having limited permission. What should I do to the binary file in order to use the same .so files from so...

Limiting syscall access for a Linux application

Assume a Linux binary foobar which has two different modes of operation: Mode A: A well-behaved mode in which syscalls a, b and c are used. Mode B: A things-gone-wrong mode in which syscalls a, b, c and d are used. Syscalls a, b and c are harmless, whereas syscall d is potentially dangerous and could cause instability to the machine....

How can I have a post-commit hook that is only called when commits are made to TRUNK?

I have a repository that has the following directories: branches tags trunk The trunk directory contains the main line of development. I have created a post-commit hook script for the repository that updates a working copy (of trunk) when a user commits back to repository. It looks something like this: /usr/bin/svn update /path/to/...

How to get return value from CHILD PROCESS?

Program calculates sum of numbers from 1 to N.. Child process calculates sum of EVEN numbers. Parent process calculates sum of odd numbers. I want to get the return value of child process in parent process. How do i do that #include<stdio.h> #include<errno.h> #include<unistd.h> #include<stdlib.h> #include<fcntl.h> int main() { int ...

When to use kernel threads vs workqueues in the linux kernel

There are many ways to schedule work in the linux kernel: timers, tasklets, work queues, and kernel threads. What are the guidelines for when to use one vs another? There are the obvious factors: timer functions and tasklets cannot sleep, so they cannot wait on mutexes, condition variables, etc. What are the other factors in choosing ...

Nested struct viewer for Linux Kernel

I am in the process of tackling the Linux Kernel learning curve and trying to get my head round the information stored in nested struct specifically to resolve a ALSA driver issue. Hence, I am spending a lot of my time in the source code tracing through structures that have pointers to other structures that in turn have pointers to yet ...