c(3)

MODULE
c - Command Interface Module

DESCRIPTION

The c module enables users to enter the short form of some commonly used commands. These functions are are intended for interactive use in the Erlang shell.

EXPORTS

bt(Pid) -> void()

    Types
        Pid = pid()

    This function evaluates erlang:process_display(Pid, backtrace).

c(File) -> CompileResult

    This function is equivalent to:

    compile:file(File, [report_errors, report_warnings])

c(File, Flags) -> CompileResult

    Types
        File = atom() | string()
        CompileResult = {ok, ModuleName} | error
        ModuleName = atom()
        Flags = [Flag]

    This function calls the following function and then purges and loads the code for the file:

    compile:file(File, Flags ++ [report_errors, report_warnings])

    If the module corresponding to File is being interpreted, then int:i is called with the same arguments and the module is loaded into the interpreter. Note that int:i only recognizes a subset of the options recognized by compile:file.

    Extreme care should be exercised when using this command to change running code which is executing. The expected result may not be obtained.

    Refer to compiler manual pages for a description of the individual compiler flags.

cd(Dir) -> void()

    Types
        Dir = atom() | string()

    This function changes the current working directory to Dir, and then prints the new working directory.

flush() -> void()

    This function flushes all messages in the shell message queue.

help() -> void()

    This function displays help about the shell and about the command interface module.

i() -> void()

    This function provides information about the current state of the system. This call uses the BIFs processes() and process_info/1 to examine the current state of the system. (The code is a good introduction to these two BIFs).

i(X, Y, Z) -> void()

    Types
        X = Y = Z = int()

    This function evaluates process_info(pid(X, Y, Z)).

l(Module) -> void()

    Types
        Module = atom() | string()

    This function evaluates code:purge(Module) followed bycode:load_module(Module). It reloads the module.

lc(ListOfFiles) -> Result

    Types
        ListOfFiles = [File]
        File = atom() | string()
        Result = [CompileResult]
        CompileResult = {ok, ModuleName} | error
        ModuleName = atom()

    This function compiles several files by calling c(File) for each file in ListOfFiles.

ls() -> void()

    This function lists all files in the current directory.

ls(Dir) -> void()

    Types
        Dir = atom() | string()

    This function lists all files in the directory Dir.

m() -> void()

    This function lists the modules which have been loaded and the files from which they have been loaded.

m(Module) -> void()

    Types
        Module = atom()

    This function lists information about Module.

memory() -> TupleList

    Types
        TupleList = [TwoTuple]
        TwoTuple = {atom(), int()}

    A list of tuples is returned. Each tuple has two elements. The first element is an atom describing memory type. The second element is memory size in bytes. A description of each tuple follows:

        total:
            The total amount of allocated memory. total is the sum of processes and system.

            Observe that this is not a complete list of allocated memory; but, it is almost complete.

        processes:
            The total amount of memory allocated by the processes.

        system:
            The total amount of memory allocated by the system. Memory allocated by processes is not included.

            Observe that this is not a complete list of memory allocated by the system; but, it is almost complete.

        atom:
            The total amount of memory allocated for atoms.

            This memory is part of the memory presented as system memory.

        atom_used:
            The total amount of memory actually used for atoms.

            This memory is part of the memory presented as atom memory.

        binary:
            The total amount of memory allocated for binaries.

            This memory is part of the memory presented as system memory.

        code:
            The total amount of memory allocated for code.

            This memory is part of the memory presented as system memory.

        ets:
            The total amount of memory allocated for ets tables.

            This memory is part of the memory presented as system memory.

        maximum:
            The maximum total amount of memory allocated since the Erlang runtime system was started.

            This tuple is only present when the Erlang runtime system is run instrumented.

    A process executing this function may be preempted by other processes; therefore, the returned information may not be a consistent snapshot of the memory allocation state.

    The total and system values are more accurate when the Erlang runtime system is run instrumented.

    More tuples in the returned list may be added in the future.

memory(MemoryType) -> int()

    Types
        MemoryType = atom()

    MemoryType is one of the following atoms: total, processes, system, atom, atom_used, binary, code, ets, or maximum. These atoms correspond to the atoms described for memory/0 above. The amount of memory in bytes that corresponds to the argument is returned.

    A process executing this function may be preempted by other processes; therefore, the returned information may not be a consistent snapshot of the memory allocation state.

    The total and system values are more accurate when the Erlang runtime system is run instrumented.

    More arguments may be added in the future.

    Failure: badarg if MemoryType isn't one of the atoms listed above, or if the Erlang runtime system isn't run instrumented and MemoryType is maximum.

nc(File) -> void()

    Types
        File = atom() | string()

    This function compiles File and loads it on all nodes in an Erlang nodes network.

nc(File, Flags) -> void()

    Types
        File = atom() | string()
        Flags = [Flag]

    This function compiles File with the additional compiler flags Flags and loads it on all nodes in an Erlang nodes network. Refer to the compile manual pages for a description of Flags.

ni() -> void()

    This function does the same as i(), but for all nodes in the network.

nl(Module) -> void()

    Types
        Module = atom()

    This function loads Module on all nodes in an Erlang nodes network.

nregs() -> void()

    This function is the same as regs(), but on all nodes in the system.

pid(X, Y, Z) -> pid()

    Types
        X = Y = Z = int()

    This function converts the integers X, Y, and Z to the Pid <X.Y.Z>. It saves typing and the use oflist_to_pid/1. This function should only be used when debugging.

pwd() -> void()

    This function prints the current working directory.

q() -> void()

    This function is shorthand for init:stop(), i.e., it causes the node to stop in a controlled fashion.

regs() -> void()

    This function displays formatted information about all registered processes in the system.

xm(ModSpec) -> void()

    Types
        ModSpec = Module | File
        Module = atom()
        File = string()

    This function finds undefined functions and unused functions in a module by calling xref:m/1.

zi() -> void()

    This function works like i(), but additionally displays information about zombie processes, i.e., processes which have exited, but which are still kept in the system to be inspected.

See Also

instrument(3)

AUTHORS
Joe Armstrong - support@erlang.ericsson.se
Robert Virding - support@erlang.ericsson.se
Claes Wikstrom - support@erlang.ericsson.se