Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Post History

66%
+2 −0
Q&A VISUAL=gvim makes crontab -e open a new crontab instead of a current one

Specific answer: Use gvim -f. General answer: Use the non-forking mode of your editor, i.e. if you run it in a terminal, it should wait until the editor is closed to return back control to you. E...

posted 1y ago by Quasímodo‭  ·  edited 1y ago by Quasímodo‭

Answer
#3: History hidden by user avatar Quasímodo‭ · 2023-11-15T17:41:59Z (about 1 year ago)
Detailed history before this event is hidden because of a redaction.
Specific answer: Use `gvim -f`.

General answer: Use the non-forking mode of your editor, i.e. if you run it in a terminal, it should wait until the editor is closed to return back control to you.

### Explanation

Look in [crontab.c, starting at `switch (pid = fork())`](https://salsa.debian.org/debian/cron/-/blob/master/crontab.c#L393) line.

Cron creates a temporary file for you to edit its contents. Then it forks.

The child process [exec](https://linux.die.net/man/3/exec)'s your editor of choice.

The parent process waits on the child process to terminate via [wait/waitpid](https://linux.die.net/man/3/waitpid). Now, some GUI editors (of which Gvim is an example) fork to release control of the shell back to the user. So wait/waitpid returns as soon as that happens, and Cron considers that you finalized editing the temporary file, removes it, and at the point Gvim gets to actually load it, Cron was most likely faster and the file doesn't even exist anymore (this is racy though), at which point you get "... no changes made to crontab" or "No modification made" in stderr.

The exact message depends on whether your distribution patches Cron, such as Debian with [Allow-editors-with-tmpfiles.patch](https://salsa.debian.org/debian/cron/-/raw/master/debian/patches/fixes/Allow-editors-with-tmpfiles.patch).

Side note 1: This is probably something worth reporting upstream or to your distribution as non-obvious behavior to be, if not fixed, documented.

Side note 2: That's certainly not the last program you will encounter that expect a non-forking editor.
#2: Post edited by user avatar Quasímodo‭ · 2023-11-15T17:41:59Z (about 1 year ago)

The detailed changes of this event are hidden because of a redaction.

#1: Initial revision by user avatar Quasímodo‭ · 2023-11-14T22:28:00Z (about 1 year ago)

The detailed changes of this event are hidden because of a redaction.