Skip to content
Advertisement

Tag: c++

The implementation of Linux kernel current macro

Generally speaking, if we want to use current macro in Linux kernel, we should: but there is a asm-generic version: the asm version implements the current macro through per-cpu variable, but asm-generic version implements the current macro through thread_info, these two are totally different. Linux kernel headers’ organization says we should use asm version, which include asm/current.h, but so many

libuv: difference between fork and uv_spawn?

Recently I have been playing around with Libuv. I don’t get the programming model as far as child processes are concerned. For example look at the following code: Here the output printed on console is: In my understanding uv_spawn acts like fork(). In child process the value of r is 0 and in parent process it is non-zero. So from

scanf does not work in batch mode programming

I am facing issue in my code it works perfectly fine when I try to execute in linux terminal in interactive mode shown here enter image description here but when trying to do in batch mode I am getting an unexpected behaviour from program I do not know exactly is it the address like enter image description here mydata.txt contains

bad file descriptor: error on accept() (socket)

I am trying to write a simple chat application using TCP protocol in Linux, in which server receives strings from the client and it sends strings size to the client. When I run client, the server throws a “Bad file descriptor” error and exits. Nevertheless if I send input strings by client it receives correct sizes of strings, but as

C++ including Python.h compiling using makefile

I am trying to compile a C++ program which uses Python.h to execute some python scripts. Before adding the python, I had a makefile which works perfectly. I added the code to run the python script, which involves including the Python.h file. I edited the makefile to include this file, without success. My makefile: I already installed following libraries: sudo

Parallel TCP connection using threads

I am trying to build a system that opens parallel TCP sockets using threads. My threads are triggered using message queue IPC , thus every time a packet arrive to the message queue a thread “wakes up” , open TCP connection with remote server and send the packet. My problem is that in Wireshark , I can see the the

Syntax error calling Python from C with fork-execv

I want to call a Python script as a child process from a C program using fork and execv. I have tested it calling bin/ls and it works: So I changed the C code to call the Create_Buffer() function in this Python file: The Python script has two functions; I want to call Create_Buffer(), so I changed my C file

Can’t compile sample bpf program, bpf/bpf.h is missing

I’m trying to compile the sample bpf program in Linux source code. So I downloaded the current kernel source code and entered samples/bpf folder Then I tried to compile a sample program with gcc: And I’m unable to find bpf/bpf.h with apt-file What was wrong? Answer The Linux eBPF samples come with a rather long Makefile. It handles a lot

Advertisement