linux

libpcap packet size

I'm working with libpcap in C on linux (centos) and I'm following this guide I want to simply print out the entire packet in ascii and i'v managed to get it working by casting it a u_char* in the "my_callback" function. But I can't figure out how to get the length of the data. strstr didn't work. the header has a len member that you can ...

linux thread synchronization

I am new to linux and linux threads. I have spent some time googling to try to understand the differences between all the functions available for thread synchronization. I still have some questions. I have found all of these different types of synchronizations, each with a number of functions for locking, unlocking, testing the lock, ...

Move/copy files/folder in linux/solaris using only bash built-ins

There was a situation when somebody moved the whole rootdir into a subdir on a remote system, thus all the system tools like cp, mv, etc didn't work anymore. We had an active session though but couldn't find a way to copy/move the files back using only bash built-ins. Do somebody know of a way to achieve this? I even thought about copy...

linux, LD_PRELOAD error

Hello, i am new in programming under linux and trying to get working this code: http://scaryreasoner.wordpress.com/2007/11/17/using-ld_preload-libraries-and-glibc-backtrace-function-for-debugging/ but getting error: "ERROR: ld.so: object 'libwrap_ioctl.so' from LD_PRELOAD cannot be preloaded: ignored." what can cause it? system - Arch...

prevent linux thread from being interrupted by scheduler

How do you tell the thread scheduler in linux to not interrupt your thread for any reason? I am programming in user mode. Does simply locking a mutex acomplish this? I want to prevent other threads in my process from being scheduled when a certain function is executing. They would block and I would be wasting cpu cycles with context ...

How do I prevent export of symbols from statically linked library?

I have created a shared library on linux x86. In creating it, I have statically linked in openssl. OpenSSL is only used internally however I see that the openssl symbols have been exported. This is causing problems for other libraries that need my library AND openssl because the wrong symbol can be loaded at runtime. Is there a way t...

How to export C++ functions with GCC?

I'm using Code::Blocks to compile a shared library on Ubuntu. When I make a simple main.c file with: void* CreateInterface() { int* x = (int*)malloc( sizeof( int ) ); *x = 1337; return x; } This works fine and I can find the function CreateInterface with dlsym in another application. However, I want the function to create ...

Segmentation fault in Thread pool

i am creating a bluetooth based server program in Bluez which basically handles connections from multiple devices. I have constructed two threads; one to scan the remote devices and another to connect with the devices that are broadcasting the service. Again, a separate thread is extracted from a thread pool for each of the newly connect...

What obstacles and limitations will I face by choosing Linux + Mono + C# + MySQL for a web application?

Is this combination possible at all? If yes, will I still need to buy Visual Studio? Will I be able to use MySQLi via C#? Thank you. Update: So, does it mean I can use anything from C# ASP.NET (like controls) and it'll work under Mono? ...

Removing last two chars from each line in a text file

How do I remove the last two chars from each line in a text file using just Linux commands? Also my file seems to have weird ^A delimiters in it. What char does ^A correspond to? ...

regarding setup (object file)

i have made a firewall project in c language on linux operating system ,now i want to know how to make set of this project so that i can run this application on other system by installing it ? ...

Create setup for Linux C project

I want to create a setup for my project so that it can be installed on any pc without installing the header files. How can I do that? ...

How to retrieve the process start time (or uptime) in python

How to retrieve the process start time (or uptime) in python in Linux? I only know, I can call "ps -p my_process_id -f" and then parse the output. But it is not cool. ...

send() always interrupted by EPIPE

I've this weird behaviour in a multithreaded server programmed in C under GNU/Linux. While it's sending data, eventually will be interrupted by SIGPIPE. I managed to ignore signals in send() and treat errno after each action because of it. So, it has two individual sending methods, one that sends a large amount of data at once (or at le...

How do you debug c/c++ source code in linux using emacs?

Hello all, I am using emacs and autotools, to write and compile c/c++ sources on linux. I am using gdb via GUD in emacs. I have defined for convenience: F7:compile, F10:gud-next, F11:gud-step, F5:gud-cont, F9:gud-tbreak, F8:gud-until, F4:gud-print. I am mainly interested in debugging c/c++ source code on linux from emacs and I would lik...

how to acess and change variable of kernel space from user space

i, I have posted query previously and i am repeating same I want to modify igmpv3 (Linux) which is inbuilt in kernel2.6.-- such that it reads a value from a file and appropriately decides reserved(res 1) value inside the igmpv3 paket which is sent by a host. I want to add more to above question by saying that this is more a generic q...

can't make svn store password, even though the configuration is set to allow it

did everything the book says, i.e. removed the authentication files from .subversion/auth, and explicitly set the relevant config parameters to 'yes' even though this is a default, and yet the shell svn commands ask for password each time. The repository is on cvsdude.com, the client is linux. I also use the subclipse plugin that caches ...

Is it possible to view the "source" for a ksh function?

Our ksh environment defines several functions. The names of these functions can be listed using then typeset -f ksh command (or the functions alias). Is it possible to see the definition (ie source code) for these functions? This seems like an obvious question, but I've tried all manner of parameters to typeset -f with no luck. As an...

What are the main reasons against the Windows Registry?

If i want to develop a registry-like System for Linux, which Windows Registry design failures should i avoid? Which features would be absolutely necessary? What are the main concerns (security, ease-of-configuration, ...)? I think the Windows Registry was not a bad idea, just the implementation didn't fullfill the promises. A common pla...

mprotect - how aligning to multiple of pagesize works?

Hi, I am not understanding the 'aligning allocated memory' part from the mprotect usage. I am referring to the code example given on http://linux.die.net/man/2/mprotect char *p; char c; /* Allocate a buffer; it will have the default protection of PROT_READ|PROT_WRITE. */ p = malloc(1024+PAGESIZE-1); if (!p) { perror("Couldn't m...