Skip to content

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…