Skip to content

Get/Set the pthread scheduling policy in Linux

The code below is a sample provided by the book in my Operating Systems course. When compiling it I get the error shown below it. I compiled it using this command… However, I get this error. I tried adding -pthread: but the error remains. Thanks for your help! Answer You have the correct compiling comma…

Simple way to call ‘cat’ from c++?

I am writing some C++ code and I need to pre-allocate an array based on the contents of a file. I can definitely read the the file and parse the strings a certain way, but it’s must easier to find the proper number from the following Linux one-liner: What is the best way to use this single one liner on

waitpid() gives incorrect exit code

I’ve got a function for starting a process, and then returning the stdout and exit code. However I’ve noticed that it claims that every process returns the exit code of 1. I control the executable being invoked and I had it print to stdout the exit code, so I’ve confirmed that when it &#8220…

deactivate:unset:1: no such hash table element: pydoc

I am trying to setup my new laptop’s development environment. After install zsh I am constantly getting error deactivate:unset:1: no such hash table element: pydoc Please help. I have following simple aliases in my zshrc: Answer You can see virtualenv pr on github. or you can change deactivate () functi…

get available memory in gb using single bash shell command

following command returns available memory in kilobytes cat /proc/meminfo | grep MemFree | awk ‘{ print $2 }’ can some one suggest single command to get the available memory in gb? Answer Just a slight modification to your own magical incantation: P.S.: Dear OP, if you find yourself invoking grep …

grep mac address – 2 consecutive lines

My file consists of scan results. Each result can have 4-20 lines I want to filter only MAC addresses for Successful (Passed scans) My file: I would like to extract list of mac addressees that Passed scans. So in example if line contains “PASSED” and next line or 2 contain mac address … prin…

sh file can’t work well but commands in sh can

I’m using a bash shell to export some path,like this: env.sh: after call sh env.sh,I call echo $GOPATH ,but nothing output,and I call export again to check the variables exported,but GOPATH isn’t included.But when I copy these commands in the shell file,and execute them directly in command line,it…

Design of multi-threaded server in c

When trying to implement a simple echo server with concurrent support on linux. Following approaches are used: Use pthread functions to create a pool of thread, and maintained in a linked list. It’s created on process start, and destroy on process termination. Main thread will accept request, and use a …

Bash – Locate Script and Execute with Options

I did a good bit of searching and testing on my own, but I can’t seem to find the best way to achieve this goal. I would like to have a bash one liner that will find a script on the machine, execute the script and have the ability to add switches or needed information in my case to execute