Truth, Computing and Fail

  • rss
  • Home
  • About

Moving to Google Code

anomit | June 27, 2009

I have decided to move some of my personal projects to Google Code so that it’d give me some impetus and make me get off my lazy ass and actually put some real effort into the things I like.

Er, not really. It’s more of a selfish decision. Right now I want other people to read and criticize my code so that I’d know where I’m going wrong and correct myself. Nothing’s more dangerous than complacency.

As a starter, I have uploaded the tiny mpd now playing plugin I wrote for xchat about an year ago when I was learning socket programming in python. Showing the current playing track was too easy. Right now I want it to become more like an interface to mpd that provides basic controls sitting in the comfort of xchat.

I named the project mpd-xchat

PS: Just after I had uploaded the code, I found a project by the name of xchat-mpd :P

I hope to add one more project in the next few days :)

Comments
2 Comments »
Categories
Coding, GNU/Linux
Tags
mpd, python, xhcat
Comments rss Comments rss
Trackback Trackback

Resource limits – Part II (hard limits)

anomit | June 26, 2009

So much for late night coding. Yesterday I missed out on a very important part about setting the hard limits on resources. But you need to have a superuser process to achieve this. Referring to the code of exec.c in the previous post, put in this after line no. 18.

limit.rlim_max =1;

This is actually the hard limit and as the man page says, it acts as a ceiling for the soft limit i.e. rlim_cur. The advantage being that if the process exceeds the limit and yet continues running such as by handling the SIGXCPU signal in the previous example, this time a SIGKILL will be issued which would force it to terminate.

Now compile exec.c as usual and run it as root. You won’t see any output as we set the hard limit equal to the soft limit.

  • Soft limit reached, SIGXCPU sent
  • Process tries to handle it
  • At the same time the hard limit i.e. the ceiling for soft limit is reached too. So a SIGKILL is sent and the process terminates before any output.

References


setrlimit(2) man page

Comments
No Comments »
Categories
Coding, GNU/Linux
Tags
ipc, linux, syscall
Comments rss Comments rss
Trackback Trackback

Resource limits on an exec()-ed process

anomit | June 25, 2009

This might seem trivial at first sight but you have no idea how darn happy I’m to see this works :D . So happy that I decided to blog about it. I already hear trumpets blowing in the distance.

Here is what I was worried about:

Normally, exec() is carried out in a forked process. Setting resource limits on a forked process is straightforward using setrlimit(). But I was apprehensive whether those limits would hold once I exec() another binary image within that forked process, and it wouldn’t be overstating it if I said I was about to front kick my laptop in joy :P .

I tested by limiting the amount of CPU time(RLIMIT_CPU) that a running process is allocated since this would be the easiest to test IMO. The signal delivered to the process when it exceeds the CPU time limit is SIGXCPU.

Since this is all that is to it, wasting no more words, let’s get our hands dirty.

The program in which a process is forked and exec() is run (exec.c):

#include <stdio.h>
#include <stdlib.h>
#include <sys/resource.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>

int main()
{
    int pid;
    int rv;

    if (!( pid=fork() ))
    {
        struct rlimit limit;
        getrlimit(RLIMIT_CPU, &limit);

        limit.rlim_cur = 1;

        setrlimit(RLIMIT_CPU, &limit);

        execl("./inf","inf",NULL);
    }
    else if(pid)
    {
        wait(&rv);
    }
    else
        printf("Error forking\n");

    return 0;
}

The program whose binary image is specified in exec() (inf.c):

#include <stdio.h>
#include <stdlib.h>
#include <signal.h>

void handler(int signum)
{
    if (signum == SIGXCPU)
        printf("Caught SIGXCPU signal, exec in peace\n");
}

int main()
{
signal(SIGXCPU, handler);
while(1);
return 0;
}

Now compile
$gcc -Wall exec.c -o exec
$gcc -Wall inf.c -o inf

and run
$./exec

You’ll see SIGXCPU being handled which means the resource limit is working!

Comments
No Comments »
Categories
Coding, GNU/Linux
Tags
linux, syscall, unix
Comments rss Comments rss
Trackback Trackback

Pimp my Vim

anomit | June 18, 2009

I’ve spent the past few weeks changing the look and feel of my Vim environment. One fine day I decided to explore some :colorscheme while I was on GVim apart from the classic ’slate’ that I always use.

Now, now. I can already see purists scoffing at me for using GVim. The main reason for me using GVim is just for the occasional visual treat. While you are on the terminal and working on Vim, you don’t really have much choice of beautifying things within the editor itself. You rather have to make some changes to the terminal profile about the background/font color, font to be used and all that stuff.

Coming back to where I started off, I googled and found a few color schemes. This caught my eye because it claimed to be The last vim color scheme you’ll ever need. Apparently this was supposed to give GVim a TextMate kinda look but applying the colorscheme is only the first step. You need to set the proper fonts and background too. I suggest you checkout the vimrc and gvimrc of the author of the linked post.

Important!

You need the Monaco font to get the right look. Follow the easy steps here to install it on Ubuntu. I’m sure similar guides will be available for other distros too.

After all was done, I didn’t find the final outcome to be that impressive. In addition to GVim being buggy on occasions like no input displayed in the command mode, this time it would get stuck after I’d scroll down or up about 20 lines for like a second. Besides, it wasn’t looking too great. See for yourself.

gvim

Now it was time to make some changes to gnome-terminal and see if it suited my tastes. As usual none of set backgorund=dark and colorscheme ir_black showed the necessary changes within Vim. This part is easy. Just make a new terminal profile with the following options:

  • White on black for foreground/background
  • Font:Monaco with size 12

After this just add the following lines to your .vimrc

set background=dark
colorscheme ir_black

Switch to the new profile, open up Vim and see the difference in the richness of the colors and better font rendering.

vim

Bonus Tip

If you are a python coder, you might want to look into this post by Samuel Huckins on making Vim a complete IDE for python development. I’ve been using the NERDTree and code folding plugins mentioned there and they have been of really great help.

Comments
No Comments »
Categories
Coding, GNU/Linux
Tags
Coding, gvim, plugins, python, vim
Comments rss Comments rss
Trackback Trackback

Sam : Lucifer’s bitch

anomit | May 15, 2009

If that didn’t make any sense to you, it is related to the TV series Supernatural. Not interested? Move along.

This is a chat excerpt with Harsh on 5th April:

10:06 AM qwertymaniac: :p
me: what
qwertymaniac: its getting true more and more, that lucifer will come into
sam’s body like you predicted :p

So basically I predicted it even earlier than 5th April. All you thickheads who could finally get a hint only after seeing the final episode teaser, well……I have nothing to say :P

PS: You have no idea about my fanboyism regarding this show which is also heightened by the fact they always play classic rock in it. So yeah, if you have anything bad to say about it here, shut your whore mouth.stfu

Comments
2 Comments »
Categories
Entertainment
Tags
dean, sam, supernatural
Comments rss Comments rss
Trackback Trackback

Guns N’ Roses and Cinderella

anomit | May 3, 2009

I have never understood why Axl Rose got all the fame and fortune lavished on him while Tom Keifer was left to rot away in one forgotten corner of the memory of rock lovers. The sound of both the bands were a welcome departure from the generic hard rocking music of the 80s, if I’m to believe all those who lived through that era.

Now, the music of Guns N’ Roses is described as something to be like gritty, slick, dirty, street-smart and unpolished contrary to the kind that was being churned out by the pop metal bands of the day. So why forget Cinderella? Here is a band whose frontman was hugely influenced by the Blues records from Delta Records, who happened to sing tracks heavily inspired by both R&B and C&W genres with a hint of hard rock like Bad Seamstress Blues, One for Rock ‘n Roll, Dead Man’s Road and a lot of them!

Why oh why?

Comments
No Comments »
Categories
My Life, Nostalgia
Tags
blues, country, music, rock
Comments rss Comments rss
Trackback Trackback

Adding a new system call to the linux kernel

anomit | April 6, 2009

I tried this thing last semester too but I wasn’t too serious about it. I had decided to go for gentoo for obvious benefits that’d support the frequent rebuilding of the kernel. Somewhere down the line gentoo got caught in a cyclic dependency error and I forgot about the whole thing. But I am digressing.

Anyway, I built gentoo from scratch and got things working. This step by step guide is quite good to get started. Note that this is about adding system calls to the kernel, not implementing them.

The guide is a bit old though, and just one thing needs to be changed. Step #16 mentions the use of the _syscallN macro. Don’t use it. From the man page of _syscall

NAME

_syscall – invoking a system call without library support (OBSOLETE)

NOTES

Starting around kernel 2.6.18, the _syscall macros were removed from header files supplied to user space. Use syscall(2) instead.

The _syscall() macros do not produce a prototype. You may have to create one, especially for C++ users.

Instead use a function wrapper like this:

long mycall(int i, int * result)

{

	return syscall(__NR_mycall, i, result);

}

i and result are the arguments I used for my syscall and quite obviously it would vary according to whatever you decide to write.

There are quite a few other guides too on this topic but they are generally old and not updated. So in any case you do need to poke around quite a bit to get things working.

Some really good reading material:

  • Kernel command using Linux system calls ( uses the _syscallN macro in examples )
  • Playing with the cr0 register. This is a bit advanced for my current knowledge level and I’m in the process of fully understanding how the register works. Try at your own risk.
Comments
No Comments »
Categories
Coding, GNU/Linux
Tags
hacking, kernel, linux, syscall
Comments rss Comments rss
Trackback Trackback

TMJ bullshit, revisited

anomit | April 5, 2009

Read to gain an insight into Ramanathan Subramaniam’s sunshine-up-the-ass[1], everything’s-fine-but-not-us view of Manipal.

This freedom to live life on their own terms, to decide for themselves what they want and it makes them understand how difficult it is to take decision sometimes

enough
Regular readers of this blog must be by now familiar with the knuckleheaded rules of the authorities that I have been putting up often.

There have been a lot of additions, of a whole new level of douchiness, to those rules and I was waiting for a few more (!) to aggregate and dissect them one by one. But this neo-Gandhian claptrap has forced me to cut short my period of silence. So let there be light.

“Freedom to live life on their own terms, to decide for themselves what they want”

notice
Hell yeah! Click on the image and read #4. What does it say? “Police have been requested to detain students roaming around the campus after 12:00AM midnight”. Right. Detain. The cream of India’s criminal society have all converged upon Manipal and the fatass police force will save the day. Say hurray for them! There are so many things wrong with the whole point and I don’t even know where to start. For starters, as I have already said in my earlier posts, there is no fucking law in the country that would stop you from venturing out in the night unless some curfew has been imposed on the area due to riots. But trust the assholes here to turn around every law on its head with their money power and clout, running a clear cut case of parallel government with self-styled rules that are very much at heads-on with the laws of the land. The audaciousness of the University to order the detention of students found outside the campus is mind blowing. It has been said that power blinds people and this is a very good example of it. Is the police force a plaything of the University, or are they hired? Have the students entered into some kind of Devil’s deal with the University that allows the latter to intervene in their personal affairs (and maybe own their souls too)? Also, what the fuck is it with the midnight deadline? Right now, Manipal is at its worst kind of weather and add to that craptastically designed hostels that allow the least amount of airflow within them. If we were at our home town, it’d be very natural for us to take a stroll around and enjoy the night breeze. But here, it usually involves at least 10 different kind of profanities to get the guards to open the gates. So much for the freedom to live life on my own terms.

Now they decide what you should eat, where you should live and what not. What next? University branded underwear?

Also, the incident that the linked TMJ article reports only serves to highlight the ineffectiveness of the gazillion number of guards they have placed everywhere who don’t serve the purpose of representing a vibrant campus even closely. If there is one angle of the whole issue that goes unreported even by TMJ, the self-proclaimed champion of truth, it is the harassment of the timid, unassuming students by the security guards and of the girls by the ‘matrons’ in their hostels. I have myself seen at least five instances of students being harassed by the guards. There were this group of ten students who were just hanging out and chatting around 11 in the night. Suddenly a group of guards come out of nowhere and start shouting at them like they were driving away a pack of street dogs. Regarding the girls, if they come late to the hostels, they are forced to spend the whole night in a ‘common room’, which is just a TV room with wooden benches uncomfortable for even sitting properly. What kind of fuckery is this? No one signed up for this shit. I’m not even a little bit amused at this turn of events. It has been the latest trend among the ones lower down the administration order to needlessly harass the students, just for kicks. I can’t comprehend by what stretch of logic these uneducated, illiterate ( or at best semi-literate ) akkas are allowed to push around girls a thousand times more intelligent and qualified than them. If it were not for the non-existent recruitment standards of the hostels, they would have been sweeping floors and slaving it all around the town only for a few hundred rupees. But then fools tend to forget where they stand.

I hope you remember Pravin Madhukar Pawar, the SP, who uttered these memorable words:

Student nuisance in Manipal won’t be tolerated

Looks like he finally ran into the nuisance causers.

Coming back to the world of pink bubblegum virtues extolled by Mr Ramanathan, he goes on to condemn the students who did nothing but “stood there in dismay, in anger, in frustration, in fear, in amusement, or with carelessness and an attitude of ‘why should I care?’”. Nice, just that it makes a childish assumption that you can put the world in black and white, like those who felt bad and those who were nonchalant about the whole thing. I’ll let you into a secret. The world has “shades of gray”, like the new age character actors like to call it. There were also people in the crowd who sympathized with the devil on the bike. The reason for such a shocking behavior shouldn’t be too hard to understand. With each stupid and draconian rule imposed on day-to-day activities of the students, they have grown increasingly frustrated at the administration but unable to vent it. So when someone decides to take on the same administration heads on, people will silently cheer for him. Therein lies the most dangerous aspect of this reckless display of power by the authorities. It has only served to turn the students against them and with a hostility rarely seen out of battlefields. The situation is just the right kind for the dudes who would just want to cause havoc and anarchy, who are plain evil. They have no kind of ideological commitment, but they will utilize this situation to the fullest to further the damage. I am ready to bet my life on it that if such an incident had happened a couple of years ago, there wouldn’t be any bystanders but a group of students handing him over to the police. There are only 2 ways out of this:

(a) The authorities understand that the situation has gone out of control and behave in a rational manner while framing rules

(b) The current set of people in charge of things just need to step down

But seriously, I’m sure neither of these will happen. Not with eagles breathing down your neck. The fuglification of the campus with barricades, walls and all that shit will continue unabated in the name of security and spearheaded by a bunch of lunatic individuals who are here to implement their personal vendetta, likes and dislikes instead of giving a bit of breathing space to logic and rationale.

I rest my case.

[1] This phrase is an invention by Ted Dziuba and full credits to him

Comments
13 Comments »
Categories
My Life
Tags
college, fuckery, manipal, rant, suppression
Comments rss Comments rss
Trackback Trackback

Airfail

anomit | March 4, 2009

I couldn’t find a better title for the post than this. This is also being used as a hashtag on twitter.
this-is-unacceptable
Basically it boils down to a few plain and simple facts.

  • Airtel had been clearly overselling their network infrastructure all the while. Now that people have been truly utilizing the full capability of their connections, it has driven a red fucking hot rod through Airtel’s arse and it’s hollow claims.
  • One of the envelopes containing the Airtel monthly bill had Zaheer Khan, Saif Ali Khan, Kareena Kapoor and a few other cricketers staring at us like dorks. No wonder Airtel doesn’t find any money to finance its infrastructure expansion, if that’s the reason they are offering to justify their own version of FUP.
  • TRAI has yet again shown it is being run by a bunch of old dinosaurs by not intervening in this matter with a firm statement that’d remind the ISPs what their primary focus is supposed to be.
  • We need to get over the misconception that internet is being used either for social networking or for leeching torrents. There are a lot of people like me who stream legal, free audio from last.fm ( I have been listening to the Supernatural Radio quite often since the last one month, but that’s another story ), download alpha and beta releases of various softwares, stream videos from MIT OCW ( a single lecture video was 180+ MB ) and all that shit.

I’m willing to move away from Airtel if I get any such hint that my connection is being capped. I have done so in the past with the craptastic connection my college provides and Airtel just might be the next one.

Comments
No Comments »
Categories
My Life
Tags
airfail, airtel, stupidity
Comments rss Comments rss
Trackback Trackback

Screw you all

anomit | January 30, 2009

1. Politicians. Thanks for showing the whole world how incapable are we of governing ourselves. Just a couple of months since one of the worst terrorist attacks on India and you have truly ‘moved on’.

2. I’m looking at you, fucking wimp.
bull

There are not many words to be wasted here. I’ll keep it short. Politicians are not the problem. YOU are the problem. The so-called civilized Indian society is the problem. With all its inherent glorification of subservience, mediocrity and total disrespect for individual freedom, it has been feeding the monster of intolerance and keeping it hale and hearty. Do you know why the politicians are so interested in muffling your dick rather than worrying about the non-existent water supply in your district? It is simply because it appeals to a major section of our oh-so-puritan society. You’d know the people in this demographic. You see them everyday. Those unassuming, pushed to the corner men and women from the 60s who have already fucked up their lives and are now out to fuck yours too. Nothing appeals to them more than some morality talk on the lines of “Ah! Those were the days”. Yeah, those days, when incompetent bastards like them could actually think of eking out a living without worrying about their intellectual capabilities, or rather the lack of it. This thing is like comfort food for them. Nothing else would give them a sound sleep like going to bed being rest assured that there are righteous men out there ready to pull you down, break your spirits and see to it that you don’t dare be yourself again.

Don’t waste your time cussing politicians. They’re the true mirror of what a society really is. If they wouldn’t have had any sympathizers, they wouldn’t have been doing this.

Comments
1 Comment »
Categories
Uncategorized
Tags
India, mangalore, politicians, pub culture
Comments rss Comments rss
Trackback Trackback

« Previous Entries

What’s in

  • Moving to Google Code
  • Resource limits – Part II (hard limits)
  • Resource limits on an exec()-ed process
  • Pimp my Vim
  • Sam : Lucifer’s bitch

 

July 2009
M T W T F S S
« Jun    
 12345
6789101112
13141516171819
20212223242526
2728293031  

Blogroll

  • Akhshay’s blog
  • Harsh J
  • Hullap
  • LUG manipal
  • Manish Sinha
  • Sindhu S
  • Swap

Tags

aircrack airfail airtel assembly blues build Coding college country cryptography dean faculty fuckery gnuplot gvim hacking India ipc kernel linux mangalore manipal mpd music NASM plugin plugins politicians pub culture python rant rock sam scheduler simulation SSFNet stupidity supernatural suppression syscall syscalls unix vim xchat xml

Archives

  • June 2009
  • May 2009
  • April 2009
  • March 2009
  • January 2009
  • November 2008
  • September 2008
  • August 2008
  • July 2008
  • June 2008
  • May 2008
  • April 2008
  • March 2008
  • February 2008
  • January 2008
  • October 2007
  • September 2007
  • July 2007
  • June 2007
  • May 2007
  • April 2007
  • March 2007

License

Creative Commons License
This work by Anomit Ghosh is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.5 India License.
rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox