Skip to main content

Posts

Unix half-duplex pipes

The pipe ‘|’ is a type of inter-process communication. Its facilities provide a method for multiple processes to communicate with one another. Simply putting a pipe in between is a method of connecting the standard output of one process to the standard input of another. joset@kee$ ls -l | grep -i foo In the example above, the output of ls is written to the input of grep. Obviously, the output of grep is written to the standard output of the shell, the screen. Here is how a pipe works. #include<stdio.h> #include<unistd.h> #include<sys/types.h> int main(void) { int fd[2], n_bytes; pid_t child; char string[] = "Hello, world!\n"; char readbuf[80]; pipe(fd); if ((child = fork()) == -1){ perror("fork"); exit(1); } if ((child == 0)){ /* child process closes up input side of pipe */ close(fd[0]); /* send "string" through the output side of pipe */ write(fd[1], string, strlen(string)); exit(0); ...

A legal alien?

Yesterday, I was triggered by my ego to attend a session of WMSU’s review for the incoming ICT proficiency exam. Each student spent a total of Php 460.00 for the review and test fee. It started last week. Passers of the said exam are guaranteed to be certified ICT professionals as noted by NCC. I was curious about how the review was being held. I was able to set myself in the classroom without catching much of the professor’s attention. It was my first attempt. I was somehow excited at first, but as the review went on, the professor did not talk that much and started filling up the chalkboard. The topic was about data structures. I was surprised with what I have found out. I bet you have the idea.

A sticky lesson

With a dial-up connection reaching 14kbps at max, an ‘emerge-delta-webrsync’ consuming only 5 minutes of your uptime, a free access from 0000H - 0800H, and a script that does nasty things like disconnect after ‘emerge -f foo’ and switch to ‘init 0′, You will not be able to resist the clamor for an up-to-date box. The lesson began here: root@kee# emerge =sys-devel/gcc-3.4.4 This does not mean dirty! joset@kee$ eix -e gcc * sys-devel/gcc ... Installed: 3.3.6 3.4.4-r1 Homepage: http://www.gnu.org/software/gcc/gcc.html ... Found 1 matches joset@kee$ Not realizing that having multiple GCCs installed is normal, and without following the upgrading-gcc-guide, a stupid action followed. root@kee# emerge -C =sys-devel/gcc-3.3.6 Bang! libstdc++.so.5.0.6, where the hell are you? All programs linked dynamically to this library were paralized! My intention was to clean up gcc-3.3.6 since I have emerged gcc-3.4.4 recently. A...

The true emptiness

It is very important for me to express to you how much you really mean to me. I wish I could do this in person exquisitely. But since we are physically separated by miles of emptiness, this expression must come in the form of letters such as this. Life seems to be full of trials of this type which test my inner strength, and more importantly, my devotion and love for you. After all, it is said that “True Love” is boundless and immeasurable and overcomes all forms of adversity. In truth, if it is genuine, it will grow stronger with each assault upon its existence. I am happy this way. Life is so kind for giving someone like you as my sole inspiration. My love has been assaulted many times, and I am convinced that it is true because the longer I am away from you, the greater is my yearning to see you again. Across the miles, I send to you my tender love and my warm embrace. Thank you for being one of my life’s sweetest blessings.

Mystery program

This program is system-dependent, it will run correctly on many different systems. Try it on your machine. #if (VAX || PC)         #define HEX0 0x6c6c6548         #define HEX1 0x77202c6f         #define HEX2 0x646c726f         #define HEX3 0x00000a21 #else         #define HEX0 0x48656c6c         #define HEX1 0x6f2c2077         #define HEX2 0x6f726c64         #define HEX3 0x210a0000 #endif typedef union {         char what[16];         long cipher[4]; } mystery; int main(void) {         mystery x;         x.c...