New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"i3-msg restart" yields error code 1 even on successful restart #3565

Open
jwflory opened this Issue Dec 14, 2018 · 6 comments

Comments

Projects
None yet
4 participants
@jwflory
Copy link

jwflory commented Dec 14, 2018

I'm submitting a…

[x] Bug
[ ] Feature Request
[ ] Documentation Request
[ ] Other (Please describe in detail)

Current Behavior

$ i3-msg restart
$ echo $?
1

Restarting i3wm in place with i3-msg yields an error code of 1 – however, the restart appears to complete successfully with no clear error with debugging and verbosity enabled.

Expected Behavior

$ i3-msg restart
$ echo $?
0

Yielding the right error code allows me to run commands in a systemd unit file and script certain behavior with i3wm. Currently, whenever my systemd service restarts, it fails because the error code yields 1. However, I visibly notice the restart takes place and the desired functionality from my systemd unit file works.

This also makes it difficult for me to automate the installation of my systemd unit file with Ansible, because when the systemd service returns a failure, the running Ansible playbook halts.

Reproduction Instructions

This happens any time I call the command after logging into i3wm from gdm.

Environment

Output of i3 --moreversion 2>&-:

i3 version: 4.15 (2018-03-10)
https://github.com/jwflory/swiss-army/blob/master/roles/apps/i3wm/files/config
- Logfile URL: https://logs.i3wm.org/logs/5730225442783232.bz2
- Linux Distribution & Version: Fedora 28
- Are you using a compositor (e.g., xcompmgr or compton): no
@i3bot

This comment has been minimized.

Copy link

i3bot commented Dec 14, 2018

Sorry, we can only support the latest major version. Please upgrade from 4.15 to 4.16, verify the bug still exists, and re-open this issue.

@Airblader

This comment has been minimized.

Copy link
Member

Airblader commented Dec 14, 2018

I'm fairly sure we didn't change anything about this in 4.16 but would you mind double checking anyway? Thanks!

@Airblader Airblader reopened this Dec 14, 2018

@jwflory

This comment has been minimized.

Copy link

jwflory commented Dec 14, 2018

@Airblader Thanks, I updated to 4.16 now and confirmed the issue is still there.

I didn't realize I was out of date. It's cool @i3bot picked up on that! I wish more projects had things like this…

@Airblader Airblader added 4.16 and removed unsupported-version labels Dec 14, 2018

@jk977

This comment has been minimized.

Copy link

jk977 commented Dec 17, 2018

From what I can tell, i3-msg successfully sends the command to i3, but doesn't get a response (ipc_recv_message returns -2), causing the error status. Putting another command in the payload (e.g., i3-msg 'restart; workspace 1') makes it restart without running the second command, too. I'm not familiar enough with the project yet to know why, but I'll have more time to try figuring it out later today, if no one else has started working on a fix.

@jk977

This comment has been minimized.

Copy link

jk977 commented Dec 23, 2018

Just a quick update, the problem seems to be specifically caused by the IPC clients getting freed before a shutdown or restart. cmd_restart() in commands.c calls ipc_shutdown(), which works fine for exiting, although when restarting, the connection is closed before the client receives a response.

I think the fix would be to make the connection persist across restarts (possibly needed for #3570, too). I've been brainstorming a little on how to implement that, but I'll have more time once the holidays are over.

@jwflory

This comment has been minimized.

Copy link

jwflory commented Dec 24, 2018

@jk977 Thanks for digging into this! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment