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
Tag: c++
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
struct is it declaration or defination or some type of Object Oriented behavior in kernel source
In r8169_main.c in linux kernel source there is a struct like this I like to in first member .name but there is no data type specified and there is . before name like .name = KBUILD_MODNAME, what is it called. is this name member defined somewhere else what this static struct means I did not seen this type of struct
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
How to get Linux file permissions in .NET 5 / .NET 6 without Mono.Posix with p/invoke?
I recently found, that I can make Linux system calls from .NET relatively easy. For example, to see if I need sudo I just make a signature like this: Neat. So much easier and faster than everything else, right? This is the simplest possible system call, other use strings and structures. After some digging in the documentation and testing for