{
    "content": [
        {
            "type": "text",
            "text": "# lockmail.maildrop(1) (man)\n\n**Summary:** lockmail - create mail lock files\n\n**Synopsis:** lockmail [-r] [-t timeout] {lockfile} {program} [argument...]\n\n## Flags\n\n| Flag | Long | Arg | Description |\n|------|------|-----|-------------|\n| -r | — | — | If a regular lock fails, try a read-only lock. Use this option to lock mailbox files in a read-only directory. -t timeou |\n\n## See Also\n\n- maildrop(1)\n- sendmail(8)\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **SYNOPSIS** (2 lines)\n- **DESCRIPTION** (4 lines) — 3 subsections\n  - C-Client folder locks (14 lines)\n  - dot-locks (16 lines)\n  - File locks (12 lines)\n- **OPTIONS** (1 lines) — 1 subsections\n  - -r (7 lines)\n- **EXIT STATUS** (4 lines)\n- **SEE ALSO** (2 lines)\n- **AUTHOR** (1 lines) — 1 subsections\n  - Sam Varshavchik (2 lines)\n- **NOTES** (6 lines)\n\n## Full Content\n\n### NAME\n\nlockmail - create mail lock files\n\n### SYNOPSIS\n\nlockmail [-r] [-t timeout] {lockfile} {program} [argument...]\n\n### DESCRIPTION\n\nThis section briefly describes the locking mechanism used by lockmail.  lockmail uses three\ndifferent locking conventions in order to maximize compatibility with other mail software:\nC-Client folder locks, dot-locks, and file locks.\n\n#### C-Client folder locks\n\nMail software based on the C-Client library creates lock files named /tmp/.dddddd.iiiiii.\nHere, dddddd and iiiiii are the device number and the inode number of the mailbox file (the\nstdev and stino fields in the inode), in hexadecimal. If the process ID saved in the\nC-Client folder lock file is not valid, lockmail concludes that it's a stale lock file, and\nwill remove it.\n\nNote\nA race condition exists where a C-Client process is killed after it creates a lock file,\nbut before saving its process ID in the lock file. The race window is very small, but it\nexists. The C-Client library does not appear to ever clear out the lock file.\n\nlockmail attempts to resolve this race condition by deleting zero-length lock files that\nare at least five minutes old.\n\n#### dot-locks\n\nlockmail also creates, and honors dot-lock files. Dot-lock files are first created as\ntemporary files, then linked to lockfile.lock. The link operation fails if the dot-lock file\nalready exists.  lockmail uses an enhanced method of dot-locking, where its process ID, and\nthe name of the server where lockmail is running is also saved in its dot-lock file. If the\noperation fails due to an existing dot-lock file that was created by another lockmail process\non the same server, and the process ID no longer exists, this stale dot-lock file is removed\nimmediately. In all other situations a dot-lock file older than five minutes is considered\nstale, and removed.\n\nNote\nA failure to create a dot-lock file is silently ignored if the reason for the failure is\nbecause lockmail does not have the write permission in the dot-lock file's directory. The\nincoming mail spool directory (usually /var/mail) typically does not have global write\npermissions, so the attempt to create the dot-lock file in the spool directory will fail,\nand lockmail will be content with using file-locking only.\n\n#### File locks\n\nThe final locking mechanism lockmail uses is the operating system's file locking facility. If\nlockmail fails to obtain all three locks, lockmail will sleep for five seconds and try again.\nThe only exception is a failure to create a dot-lock because of no write access to the\ndot-lock file's directory, which is ignored. If lockmail still fails to obtain all required\nlocks in the amount of time specified by the -t option (or its default value), lockmail will\nterminate with the EXTEMPFAIL exit code.\n\nlockmail runs program after obtaining the last file lock, waits until program terminates, and\nreleases all locks.  program must terminate before any of the locks obtained by lockmail\nexpire, and are considered stale.  lockmail will then terminate with the same exit code as\nprogram.\n\n### OPTIONS\n\n#### -r\n\nIf a regular lock fails, try a read-only lock. Use this option to lock mailbox files in a\nread-only directory.\n\n-t timeout\nIf the lock attempt fails, try again for up to timeout seconds. The actual timeout is\nrounded up to the next five second interval (a lock attempt is tried every five seconds).\n\n### EXIT STATUS\n\nlockmail terminates with the same exit status as program lockmail terminates with the\nEXTEMPFAIL exit status if it was unable to obtain a lock, or if program was killed by a\nsignal.\n\n### SEE ALSO\n\nmaildrop(1)[1], sendmail(8).\n\n### AUTHOR\n\n#### Sam Varshavchik\n\nAuthor\n\n### NOTES\n\n1. maildrop(1)\nhttp://www.courier-mta.org/maildrop.html\n\n\n\nCourier Mail Server                          07/24/2017                                  LOCKMAIL(1)\n\n"
        }
    ],
    "structuredContent": {
        "command": "lockmail.maildrop",
        "section": "1",
        "mode": "man",
        "summary": "lockmail - create mail lock files",
        "synopsis": "lockmail [-r] [-t timeout] {lockfile} {program} [argument...]",
        "flags": [
            {
                "flag": "-r",
                "long": null,
                "arg": null,
                "description": "If a regular lock fails, try a read-only lock. Use this option to lock mailbox files in a read-only directory. -t timeout If the lock attempt fails, try again for up to timeout seconds. The actual timeout is rounded up to the next five second interval (a lock attempt is tried every five seconds)."
            }
        ],
        "examples": [],
        "see_also": [
            {
                "name": "maildrop",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/maildrop/1/json"
            },
            {
                "name": "sendmail",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/sendmail/8/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 4,
                "subsections": [
                    {
                        "name": "C-Client folder locks",
                        "lines": 14
                    },
                    {
                        "name": "dot-locks",
                        "lines": 16
                    },
                    {
                        "name": "File locks",
                        "lines": 12
                    }
                ]
            },
            {
                "name": "OPTIONS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "-r",
                        "lines": 7,
                        "flag": "-r"
                    }
                ]
            },
            {
                "name": "EXIT STATUS",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 1,
                "subsections": [
                    {
                        "name": "Sam Varshavchik",
                        "lines": 2
                    }
                ]
            },
            {
                "name": "NOTES",
                "lines": 6,
                "subsections": []
            }
        ]
    }
}