I have a program which opens a large number of files. I am timing the execution of a C++ loop which literally just opens and closes the files using both a C++ timer and strace. Strangely the system time and the time logged by C++ (which agree with each other) are orders of magnitude larger than the time the t…
Tag: linux
Get lines that end with “$” in a text file
I have an output like this: What i want is just this line: To be more clear, I want those line ending with a specific string. I want to grep lines that have a / character at their last column. Answer You can use $ like this: As $ stands for end of line, /$ matches those lines whose last
Which thread handles the signal?
I have 2 threads(thread1 and thread2). And I have signal disposition for SIGINT. Whenever SIGINT occurs thread 2 should handle the signal. For that I wrote below program I compiled and and run the program. for every 1 second “thread1 active” is printing and for every 3 seconds “thread2 activ…
print odd and even numbers using 2 threads using mutex in C
Two threads in the program alternately print even and odd numbers till 100. I have tried this and it worked. Is there a way to access the value of the shared data inside main and terminate the 2 threads when the value reaches 100 Answer There were few errors, in the code I posted earlier, I corrected those mi…
OS X UDP send error: 55 No buffer space available
While I was implementing RUDP in python3.3 on OSX10.9.1 I noticed that the following code actually does not do what it does on linux: (it doesn’t matter which language, same behavior for C, Java and C#/Mono) This code just keep writing a lot udp packets to 8.8.8.8, those packets get dropped after 4 hops…
Print sum of numbers in Python Script
I’ve been searching for a while and haven’t been able to figure this out. I’m running Kali Linux and I’m trying to run a very simple script and I’m not getting the output I would expect. I used to programing python on windows and the switch to Kali and I can’t get this basi…
Firefox linux (centos) responsive design image scaling
I have an arrow in circle. CSS: In windows xp (ie8,safari,opera,ff,chrome) I checked everything is ok. The image is getting bigger and smaller – no any lines. But in linux some lines appear from the right and at the bottom of the picture. I checked image several times – there are no any lines. How…
PHP upload file code works on Windows XAMPP but not on production Linux box
I’m using this PHP to upload CSV files: and it works perfectly on my dev XAMPP setup. When I deploy the site on the Linux box it behaves as if the file upload is successful but it isn’t in the desired folder or tmp folder. My form is: My browser returns from the echos: I had a friend more familiar
IntelliJ IDEA (Linux): Go to beginning/end of line
I have switched from OS X to Linux, and trying to get used to the different keyboard shortcuts in IDEA. One very important thing I cannot find is “move cursor to beginning/end of line” (Cmd-Left and Cmd-Right on OS X). Also looking at the reference card doesn’t reveal anything useful. Answer…
LINUX LISH.H list_for_each infinite loop
I’m trying to implement a list of task_struct and use it as a FIFO. In addition I need a function to go through the list and search for a particular task. My problem is that the list_for_each macro gets stuck in an infinite loop. Here below there is a snippet from my code: Thanks in advance for any tips…