Exit from man linux

Exit from man linux

Стандарт C описывает два определения EXIT_SUCCESS и EXIT_FAILURE , которые могут быть переданы exit() для обозначения соответственно успешного и неуспешного завершения.

ВОЗВРАЩАЕМЫЕ ЗНАЧЕНИЯ


СООТВЕТСТВИЕ СТАНДАРТАМ


ЗАМЕЧАНИЯ

Использование EXIT_SUCCESS и EXIT_FAILURE несколько более переносимо (на не-Unix окружения), чем использование 0 и ненулевого значения, например 1 или -1. В часности, VMS использует другое соглашение.

В BSD была произведена попытка стандартизировать коды выхода, см. файл .

После вызова exit() код выхода должен быть передан родительскому процессе. Существует три случая. Если родительский процесс установил SA_NOCLDWAIT или установил обработчик SIGCHLD в SIG_IGN, то код выход игнорируется. Если родительский процесс ожидает дочерний, то он получает уведомление о коде выхода. В обоих случаях завершаемый процесс удаляется немедленно. Если родительский процесс не указал, что он не интересуется кодом выхода дочернего процесса, и при этом он не ожидает его завершения, то завершаемый процесс превращается в «процесс-зомби» (то есть просто контейнер для единственного байта, содержащего код выхода) для того, чтобы родительский процесс мог узнать код выхода, если позднее вызовет одну из функций wait .

Если реализация поддерживает сигнал SIGCHLD, то этот сигнал поылается родительскому процессу. Не определено, посылается ли сигнал SIGCHLD родительскому процессу, установившему SA_NOCLDWAIT.

Если процесс является лидером сеанса и его управляющий терминал является управляющим терминалом сеанса, то каждому процессу в группе процессов этого управляющего терминала посылается сигнал SIGHUP, и терминал отсоединяется от этого сеанса, что позволяет захватить его новому управляющему процессу.

Если завершение процесса приводит группу процессов к потере родителя, и если любой член такой группы приостанавливается, то каждому процессу группы посылается сигнал SIGHUP, за которым следует сигнал SIGCONT.

Источник

How to Exit from Linux Man Pages

Unix and Linux operating systems generally come with short manual (man) pages which help all the users to learn about different commands and its syntax.

Even it is one of the most frequently used documentation many users get confused with exiting the man pages one they read the manual.

In this tutorial, we learn how to properly exit from man pages.

Different Ways to Exit Man Page

You can also try pressing the following keys to exit from a man page.

1. :q

2. Q

3. :Q

4. ZZ

Steps to Exit Man Page

-> Open a terminal and type man ftp (this will open manual pages for ftp application)

-> Now, press up and down arrow keys and read the whole document.

-> Once you are done press q on the keyboard and you will come out by reading the manual.

Another thing about man pages in some of the distributions of Linux is that once you quit from it, its contents are cleared off. These contents never stay once you quit from the man pages. This happens means that the default pager of viewing man is less command. Wiping out such contents is not of personal choice. Some people many like this but sometimes you really want that the contents should be visible once you are done with viewing it. You will want the information to be present in front of you. The thing here is you can definitely change this behavior. This can be done by changing the default pager for the command to more. To do this you have to add the below mentioned line in your .bashrc file of the home directory.

Читайте также:  Synology бэкап windows 10

You can also change this behavior permanently on the system then edit the file /etc/man.config (Red Hat) or /etc/manpath.config (Debian) and change the line for PAGER here. An alternate method to do this is by running command update-alternatives –config pager (Debian) and alternatives –config pager (Red Hat). This will globally change the behavior for all the available applications.

—Note the line PAGER here which is highlighted. (File: /etc/man.config)

—Changes have been made to the line PAGER.

Now, when we quit the man pages with q, it does not clear the screen.


Conclusion

Each man page comes with the following information:

— Name of the command with its short description
— A SYNOPSIS of that command and its usage
— A description of the command
— List of different options associated with that command
— List of different configuration files associated with the command

If you specify any section then man pages only look for that section our manual. Now, the question occurs here is how we generally exit from man page when we have finished viewing the same. For most of the people who are known to Linux, the answer is well known. Before discussing it more let us have a look at some basic functionality of this manual command. These manual pages are easily accessed with any terminal in Linux by simply typing man program-name. Once the page is opened you can easily navigate these pages by making use of up and down arrow keys and even in certain cases you can also use enter key to get more help. Once you are done with the viewing of manual pages, you can simply exit or close this manual by pressing “q” key. This will take you back to the command prompt in an open terminal.

Источник

exit(2) — Linux man page

_exit, _Exit — terminate the calling process

Synopsis

Feature Test Macro Requirements for glibc (see feature_test_macros(7)): _Exit(): _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L;
or cc -std=c99

Description

The function _exit() terminates the calling process «immediately». Any open file descriptors belonging to the process are closed; any children of the process are inherited by process 1, init, and the process’s parent is sent a SIGCHLD signal.

Читайте также:  Моноблок для mac os

The value status is returned to the parent process as the process’s exit status, and can be collected using one of the wait(2) family of calls.

The function _Exit() is equivalent to _exit().

Return Value

These functions do not return.

Conforming To

SVr4, POSIX.1-2001, 4.3BSD. The function _Exit() was introduced by C99.

Notes

For a discussion on the effects of an exit, the transmission of exit status, zombie processes, signals sent, and so on, see exit(3).

The function _exit() is like exit(3), but does not call any functions registered with atexit(3) or on_exit(3). Whether it flushes standard I/O buffers and removes temporary files created with tmpfile(3) is implementation-dependent. On the other hand, _exit() does close open file descriptors, and this may cause an unknown delay, waiting for pending output to finish. If the delay is undesired, it may be useful to call functions like tcflush(3) before calling _exit(). Whether any pending I/O is canceled, and which pending I/O may be canceled upon _exit(), is implementation-dependent.

In glibc up to version 2.3, the _exit() wrapper function invoked the kernel system call of the same name. Since glibc 2.3, the wrapper function invokes exit_group(2), in order to terminate all of the threads in a process.

Источник

exit(3) — Linux man page

Synopsis

Description

All functions registered with atexit(3) and on_exit(3) are called, in the reverse order of their registration. (It is possible for one of these functions to use atexit(3) or on_exit(3) to register an additional function to be executed during exit processing; the new registration is added to the front of the list of functions that remain to be called.) If one of these functions does not return (e.g., it calls _exit(2), or kills itself with a signal), then none of the remaining functions is called, and further exit processing (in particular, flushing of stdio(3) streams) is abandoned. If a function has been registered multiple times using atexit(3) or on_exit(3), then it is called as many times as it was registered.

All open stdio(3) streams are flushed and closed. Files created by tmpfile(3) are removed.

The C standard specifies two constants, EXIT_SUCCESS and EXIT_FAILURE, that may be passed to exit() to indicate successful or unsuccessful termination, respectively.

Return Value

Conforming to

Notes

It is undefined what happens if one of the functions registered using atexit(3) and on_exit(3) calls either exit() or longjmp(3). Note that a call to execve(2) removes registrations created using atexit(3) and on_exit(3).

The use of EXIT_SUCCESS and EXIT_FAILURE is slightly more portable (to non-UNIX environments) than the use of 0 and some nonzero value like 1 or -1. In particular, VMS uses a different convention.

Читайте также:  Microsoft windows system requirements

BSD has attempted to standardize exit codes; see the file .

After exit(), the exit status must be transmitted to the parent process. There are three cases. If the parent has set SA_NOCLDWAIT, or has set the SIGCHLD handler to SIG_IGN, the status is discarded. If the parent was waiting on the child it is notified of the exit status. In both cases the exiting process dies immediately. If the parent has not indicated that it is not interested in the exit status, but is not waiting, the exiting process turns into a «zombie» process (which is nothing but a container for the single byte representing the exit status) so that the parent can learn the exit status when it later calls one of the wait(2) functions.

If the implementation supports the SIGCHLD signal, this signal is sent to the parent. If the parent has set SA_NOCLDWAIT, it is undefined whether a SIGCHLD signal is sent.

If the process is a session leader and its controlling terminal is the controlling terminal of the session, then each process in the foreground process group of this controlling terminal is sent a SIGHUP signal, and the terminal is disassociated from this session, allowing it to be acquired by a new controlling process.

If the exit of the process causes a process group to become orphaned, and if any member of the newly orphaned process group is stopped, then a SIGHUP signal followed by a SIGCONT signal will be sent to each process in this process group. See setpgid(2) for an explanation of orphaned process groups.

Источник

How to exit a Linux man page

Last updated: November 14, 2007

How do I exit a man page when finished viewing? Although the answer to this question is well known, due to how many times I have been asked how to exit a man page or info page once done viewing, I thought I should put up a quick answer. Linux manual pages aka. man pages are provided with almost all software available for Linux and house important documentation about a program and explain how to use it.

Linux manual pages can be easily accessed via the terminal by typing man program-name.

Manual or info page navigation can be accomplished by using the up and down arrow keys or in some cases, by pressing enter for more

Once you are finished viewing a manual or info page, you can exit or close the manual by simply pressing q. This will return you to the command prompt within the open terminal.

Example usage of man page:

  1. Open a terminal and type man ftp (to open the manual for the ftp application)
  2. Use the up and down arrow keys on your keyboard to read the document.
  3. Once finished press q on your keyboard to quit reading the manual.

Note: Info can be used in place of man to access informational pages. For example: info ftp

Источник

Оцените статью