Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
115

If it is in your path, then you can run either type git or which git. The which command has had problems getting the proper path (confusion between environment and dot files). For type, you can get just the path with the -p argument. If it is not in your path, then it's best to look for it with locate -b git It will find anything named 'git'. It'll be a ...


61

tuxcall is the place-holder for the tux system call which was used by user-space tools to communicate with the TUX kernel module, which implemented the TUX web server. This was a web server running entirely in the kernel; it was maintained by Ingo Molnar until improvements in other parts of Linux, notably thread support with NPTL, brought user-space web ...


59

It's due to the technical constraints of the time. The POSIX standard was created in the 1980s and referred to UNIX, which was born in the 1970. Several C compilers at that time were limited to identifiers that were 6 or 8 characters long, so that settled the standard for the length of variable and function names.


44

The POSIX standard way to do this is command -v git. All UNIX-like systems should support this.


34

As for the reasoning behind the specific numbering, which does not match any other architecture [except "x32" which is really just part of the x86_64 architecture]: In the very early days of the x86_64 support in the linux kernel, before there were any serious backwards compatibility constraints, all of the system calls were renumbered to optimize it at the ...


30

As a result of the pipe in x | y, a subshell is created to contain the pipeline as part of the foreground process group. This continues to create subshells (via fork()) indefinitely, thus creating a fork bomb. $ for (( i=0; i<3; i++ )); do > echo "$BASHPID" > done 16907 16907 16907 $ for (( i=0; i<3; i++ )); do > echo "$BASHPID" | cat ...


28

Summary: you're correct that receiving a signal is not transparent, neither in case i (interrupted without having read anything) nor in case ii (interrupted after a partial read). To do otherwise in case i would require making fundamental changes both to the architecture of the operating system and the architecture of applications. The OS implementation ...


28

The fork() and vfork() wrappers in glibc are implemented via the clone() system call. To better understand the relationship between fork() and clone(), we must consider the relationship between processes and threads in Linux. Traditionally, fork() would dublicate all the resources owned by the parent process and assign the copy to the child process. This ...


26

A process's resident set size is the amount of memory that belongs to it and is currently present (resident) in RAM (real RAM, not swapped or otherwise not-resident). For instance, if a process allocates a chunk of memory (say 100Mb) and uses it actively (reads/writes to it), its resident set size will be about 100Mb (plus overhead, the code segment, etc.). ...


24

The last bit of the code, ;: is running the function :(){ ... }. This is where the fork is occurring. The semicolon terminates the first command, and we're starting another one, i.e. invoking the function :. The definition of this function includes a call to itself (:) and the output of this call is piped to a backgrounded version :. This props up the ...


24

dr01 is right, but there's also another reason - usability. Back in the day, you didn't have something as comfortable as a keyboard to type on. If you were lucky, you had something akin to an old-school typewriter. If you were unlucky, you had to deal with systems that required actual physical work to operate (as in, it took a lot of force to press the "key")...


23

About your performance question, pipes are more efficient than files because no disk IO is needed. So cmd1 | cmd2 is more efficient than cmd1 > tmpfile; cmd2 < tmpfile (this might not be true if tmpfile is backed on a RAM disk or other memory device as named pipe; but if it is a named pipe, cmd1 should be run in the background as its output can block ...


23

From the source code: if (Tflag) { ts_sub(ts, ts, &tcp->etime); tprintf(" <%ld.%06ld>", (long) ts->tv_sec, (long) ts->tv_nsec / 1000); } This means that the time is shown in seconds, with microseconds (calculated from the nanosecond value) after the decimal point.


21

System calls per se are a concept. They represent actions that processes can ask the kernel to perform. Those system calls are implemented in the kernel of the UNIX-like system. This implementation (written in C, and in asm for small parts) actually performs the action in the system. Then, processes use an interface to ask the system for the execution of ...


21

Sure! A common pattern in "wrapper" programs is to do various things and then replace itself with some other program with only an exec call (no fork) #!/bin/sh export BLAH_API_KEY=blub ... exec /the/thus/wrapped/program "$@" A real-life example of this is GIT_SSH (though git(1) does also offer GIT_SSH_COMMAND if you do not want to do the above wrapper ...


21

On recent Linux systems that is actually possible, but with block (4096 most of the time), not byte granularity, and only on some filesystems (ext4 and xfs). Quoting from the fallocate(2) manpage: int fallocate(int fd, int mode, off_t offset, off_t len); [...] Collapsing file space Specifying the FALLOC_FL_COLLAPSE_RANGE flag (available ...


19

In addition to the other answers, I would like to point out that Unix was developed as a reaction to Multics, CTSS, and other contemporary operating systems, which were significantly more verbose about their naming conventions. You can get a feel for these OSes at http://www.multicians.org/devdoc.html. For example, http://www.multicians.org/mspm-bx-1-00....


18

There are in fact three gradations in system calls. Some system calls return immediately. “Immediately” means that the only thing they need is a little processor time. There's no hard limit to how long they can take (except in real-time systems), but these calls return as soon as they've been scheduled for long enough. These calls are usually called non-...


16

Conceptually, a library function is part of your process. At run-time, your executable code and the code of any libraries (such as libc.so) it depends on, get linked into a single process. So, when you call a function in such a library, it executes as part of your process, with the same resources and privileges. It's the same idea as calling a function you ...


15

/bin/ls usually sorts the output. I'm not sure if your "efficient" question is just over system calls or the entire work that is done, but /bin/ls -f would probably do the least work. It only returns the filenames in directory order. No sorting, no additional inode lookups to get metadata (as ls -l would do). Also, if your default ls is colorizing, it ...


15

See that answer to the question "Why are the system call numbers different in amd64 linux?" on Stack Overflow. To sum it up: for the sake of compatibility, the system call list is stable and can only grow. When the x86 64 architecture appeared, the ABI (argument passing, returned value) was different, thus the kernel developers took the opportunity to bring ...


14

It is not possible because system call table (called sys_call_table) is a static size array. And its size is determined at compile time by the number of registered syscalls. This means there is no space for another one. You can check implementation for example for x86 architecture in arch/x86/kernel/syscall_64.c file, where sys_call_table is defined. Its ...


14

The file /proc/kallsyms lists all the symbols of the running kernel. By convention, system calls have a name that begin with sys_. On a 64-bit system, system calls for 32-bit programs have a name that begin with sys32_. Strictly speaking, this lists internal kernel functions, not system call, but I think that the correspondence does work (every system call ...


14

I've found something from non-standard-syscalls: tuxcall() - This call comes from a TUX module and is sent to the kernel. The call asks the kernel to perform some task for the module. A TUX module is basically a server application/daemon in the form of a Linux module. Imagine an Apache server being a kernel module; that is essentially how TUX ...


13

I believe that the idea of the socket being unavailable to a program is to allow any TCP data segments still in transit to arrive, and get discarded by the kernel. That is, it's possible for an application to call close(2) on a socket, but routing delays or mishaps to control packets or what have you can allow the other side of a TCP connection to send data ...


13

The other answers here seem to be largely geared towards modern versions of Linux, so if you happen to use git on an OS that doesn't have locate, whereis, which, or apropos (like Solaris, HPUX, etc), then there is always the old standby find. find / -name git One some older versions of the systems listed above, you may need a -print option supplied to ...


13

ls -l is definitely more expensive, since it has to query the file system for metadata such as owner, group, permissions, access time, etc. Vanilla /bin/ls only has to look up the names of the entries in the directory being listed. Note that ls may be aliased on your system to something less vanilla than /bin/ls. Run type ls to see if that's the case.


13

There are plenty. Programs that call fork() without exec() are usually following a pattern of spawning child worker processes for performing various tasks in separate processes to the main one. You'll find this in programs as varied as dhclient, php-fpm, and urxvtd. A program that calls exec() without fork() is chain loading, overlaying its process with a ...


13

If you run strace -T sleep 2 you will see nanosleep({tv_sec=2, tv_nsec=0}, NULL) = 0 <2.000230> so it looks like the time spent is in seconds.


13

Unfortunately, there is currently not a way to do this. But perhaps in the future I may add it, if I can figure out a sane interface and implementation to do such a thing. Maybe I will add a trigger that will make the output show differently. Although I may be new to StackExchange, I am the author of ftrace (real name Steven Rostedt - look up the git ...


Only top voted, non community-wiki answers of a minimum length are eligible