Makefile Tip

You might have faced Makefile not continuing with rest of the commands if any of the previous commands returns exit code as -1 or any negative values. There is a simple way for make to ignore these return codes and continue the build. Just add ‘-‘ before the command for which build is failing. Ensure that this tip is used only for the case where the tool is returning failure and the objective of the tool is working fine.

WikiLeaks Founder Julian Assange Launches ‘Google Rival’ – How Google should look like

Julian Assange, Wikileaks founder has launched a new search engine, which is a portal to an archive of 1.7 million US diplomatic cables, named as PLUSD (The Public Library of United States Diplomacy), the search engine includes 2, 50, 000 leaked State Department cables that were publicized during Cablegate.

Visit PlusD

Read more…

Single instance in Linux applications

Sometimes you may need to write an application in lnux for which multiple instances are not allowed. There is a simple way to achieve even though you have lot of other ways like semaphores, sockets etc to achieve the same. Here is a small snippet code to achieve the same using file locking.

#include <sys/file.h>

#include <sys/types.h>

#include <sys/stat.h>

#include <fcntl.h>

 

int pid_file = -1; int rc = -1;

pid_file = open(“/var/run/whatever.pid”, O_CREAT | O_RDWR, 0666);

rc = flock(pid_file, LOCK_EX | LOCK_NB);

if(rc) {

if(EWOULDBLOCK == errno)     {

close(pid_file); // another instance is running

return;

}

}

else {

// this is the first instance

}

 

Page 3 of 177
1 2 3 4 5 177