UNIX & GNU/Linux - System calls - readdir()

The readdir() system call function is used to read into a directory. The function returns a pointer to a dirent structure. This structure contains five fields but only two are POSIX standard, this is the d_name and the d_ino member. That’s the first we will use in our readdir() example. Before starting, let’s create some files. We need a folder named hello. In the hello directory, let’s create three new files: a folder named one and two files named girl and boy. ...

January 11, 2011

UNIX & GNU/Linux - tcsh - Builtin commands source

In this tutorial we will see what is the source builtin command. We will set the prompt of our tcsh as example. Let’s go. We can change the prompt with a script. But without modifying the .tcshrc file. It means that each new terminal you will open will be with the default shell config, in this case .tcshrc. Let’s make a classic script by creating a new file named tcshScript. Let’s open it and write this inside: ...

January 7, 2011

UNIX & GNU/Linux - make - Makefile

A Makefile has to be named Makefile with the first letter in capitalize. There can be only one such file. It is called with the make tool. To use it simply write make on your terminal and it will execute the rules in your Makefile. Using a Makefile is really helpful. It automates tasks you have to do. Let us take some examples: In this first example, the Variables section contains 3 variables. ...

January 6, 2011

UNIX & GNU/Linux - System call functions

List of Linux system call functions. These functions need one or more appropriate headers for each one of them. These headers can be found in this directory on your operating system: /usr/include/ And if you want to learn more of them, just write man 2 theNameOfTheFunction on your favorite shell. Example: $ man 2 open Why 2? Because it is the number chosen for the system call functions.

January 3, 2011

UNIX & GNU/Linux - System calls - fork()

The fork() function is a Linux system call function. It is used to make a new identical process from another one. The original process becoming the parent and the new process becoming its child. The both are alive at the same time. But when the fork() function is called, both process will terminate with the same end. Let us see an example of the fork() function with 3 fonctions: /* ** Made by BadproG.com */ #include void begin() { puts("#############"); puts("### BEGIN ###"); puts("#############"); } void ending() { puts("##############"); puts("### ENDING ###"); puts("##############"); } int main() { begin(); puts("Here the neutral code"); fork(); puts("Here the code after fork()"); ending(); } We compile: ...

January 3, 2011