Skip to content
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

[RFC] Getting exit status from job with job-control #1844

Closed
wants to merge 51 commits into from

Conversation

benekastah
Copy link

Fixes #1795 by making v:job_data[2] be the exit status when the
"activity" is "exit".

@benekastah benekastah changed the title Getting exit status from job with job-control Getting exit status from job with job-control [RFC] Jan 19, 2015
@fwalch
Copy link
Member

fwalch commented Jan 19, 2015

Travis failed; looks like some tests will need to be adapted as well.

@fwalch
Copy link
Member

fwalch commented Jan 22, 2015

Well, looks like a straightforward change to me, so I think it should be okay... just a few nitpicks:

  • The [RFC] should normally be prefixed to the PR title, i.e. "[RFC] Getting ...". That way it will automatically get assigned the RFC Github label by our Bot, @marvim.
  • The commits should probably be squashed in the end.
  • Maybe you could add a test with a job that returns a non-zero exit status?

@justinmk justinmk added the enhancement feature request label Jan 23, 2015
@justinmk
Copy link
Member

@benekastah This will definitely be useful. Can you add some tests that test non-zero exit statuses? And maybe other edge cases, if you can think of any.

@benekastah benekastah changed the title Getting exit status from job with job-control [RFC] [RFC] Getting exit status from job with job-control Jan 25, 2015
@benekastah
Copy link
Author

All right, I added the test for non-zero job statuses. I saw that cat was being used in that file, so I used cat. I also used bash in an effort to get a program to return an error code that wasn't just 1, but if we don't want to depend on that for the tests I can remove it.

I'm not sure how to squash my commits. After pulling upstream master into my branch, my original commits don't show up when I do git rebase -i. I tried to research this, but I couldn't figure it out. Sorry, not very experienced with history rewriting I'm afraid. Any pointers there?

@marvim marvim added the RFC label Jan 25, 2015
eq({'notification', 'j', {{jobid, 'exit', 1}}}, next_message())
nvim('command', "let j = jobstart('xxx', 'bash', ['-c', 'exit 100'])")
local jobid = nvim('eval', 'j')
eq({'notification', 'j', {{jobid, 'exit', 100}}}, next_message())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about a negative number too, and a really large number

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to wikipedia a lot of systems (including POSIX, bash) limit exit status codes to between 0 and 255. Trying values outside of this range just seems to cause integer overflow in bash. I could use 255 instead of 100 here so that both extremes are tested.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point. It could be tested with unit tests that call the C functions directly, but seems like the related functions are static, so won't be easy.

@ghost
Copy link

ghost commented Jan 26, 2015

@benekastah have you looked here? Also, are you running git rebase -i with an argument like git rebase -i HEAD~6?

@benekastah
Copy link
Author

What I did was git rebase -i f44a1e1632528536cb98b5618574eb3c2281cf17 (that hash is the commit before I started). I moved all my commits to the end, ordered chronologically and picked the first of my commits and squashed the rest. Seems to have fucked up this PR pretty good. Not sure what to do about it, apart from cherry picking my rebased commit onto another branch and opening a new PR :/

Edit: As Contributing.md suggested, I had to do a git push -f as well.

Edit 2: I was able to fix it by creating a new local branch that mirrors neovim master, cherry-picking my commit onto it, and force pushing that instead. It looks fine now, but there were tons of commits that I didn't do on here for a bit. If anyone knows why that happens, I'd love to learn.

@ghost
Copy link

ghost commented Jan 26, 2015

When you pulled, did you do something like git pull --rebase upstream master? That should rebase your commits from your feature branch on top of master, so git log -n[num of commits in this PR should only show your feature branch commits.

Edit: I see you've fixed it, great.

@benekastah
Copy link
Author

Ah, nope. I just did git pull upstream master. I'll use the --rebase one next time. Thanks for your help.

@benekastah
Copy link
Author

From what I understand, I've addressed all the comments that have come up. Let me know if there's anything I missed before it can be merged. Thanks!

@splinterofchaos
Copy link

LGTM! 👍

glebtv and others added 11 commits February 7, 2015 21:39
Problem:    Memory access error. (Dominique Pelle)
Solution:   Update tpos. (Christian Brabandt)

https://code.google.com/p/vim/source/detail?r=v7-4-514
Problem:    With a wrapping line the cursor may not end up in the right place.
            (Nazri Ramliy)
Solution:   Adjust n_extra for a Tab that wraps. (Christian Brabandt)

https://code.google.com/p/vim/source/detail?r=v7-4-517
Configuration for clang-format and related utilities.

Examples:

    clang-format -style=file <file>
    git clang-format -style=file <commit>
    git diff -U0 HEAD^ | clang-format-diff.py -i -p1 -style=file
- @justinmk: Clarify comments
- Match verbiage used in other api/*.c files
- Fix a few typos/missing words
Michael Reed and others added 24 commits February 7, 2015 21:39
It appears that commit 393c1c59a27591d705648919b2d7fb921cba37bc (unix:
set non-block mode in uv_{pipe,tcp,udp}_open) has broken Neovim's
drawing under OSX.  Let's revert to 1.2.0 until we can figure out what
is happening and get it fixed.
This makes it possible to highlight the lines starting with ~ at the end
of buffers and other elements highlighted using NonText.

As proposed by mhinz at
https://groups.google.com/forum/#!topic/vim_dev/p3de1iU1GXI/discussion
Problem    : Negative array index read @ 909.
Diagnostic : False positive.
Rationale  : Suggested error path assigns a negative value to idx at
             line 836 (`idx = find_command(ca.cmdchar);`). That's
             impossible, as `ca.cmdchar` is set to Ctrl_BSL just two
             lines above, so we know that value will be in the table.
Resolution : Assert idx >= 0.
Diagnostic : False positive.
Rationale  : Coverity thinks we are forgetting to add more char to hold
             NULL, but it's not taking into account that two chars from
             cntxformat will no be present in the result. In fact, we
             can even allocate one byte less than currently done.
Resolution : Add explanatory comment and allocate one less byte.
             Marked as "Intentional" at coverity's database.
Problem    : String not null terminated @ 1165.
Diagnostic : False positive.
Rationale  : Code below terminates string (with NUL or '\n').
Resolution : Add explanatory comment, and assert termination.
             Mark as Intentional at coverity's database.
Problem    : Argument cannot be negative @ 1165.
Diagnostic : Real issue.
Rationale  : len can be assigned a negative value @ 1162;
             len is passed as an unsigned argument @ 1165.
Resolution : Refactor variable's types:
             - Use ftello instead of ftell to avoid using long.
             - Assert ftello result is safely convertible to size_t.
             - Introduce variable read_size to avoid using i (int).
Problem    : Unitialized scalar variable @ 3239.
Diagnostic : Harmless issue.
Rationale  : It's true pos.coladd is not initialized when calling
             searchit(). But that's no problem, as coladd is only set in
             that function.
Resolution : Initialize variable to 0.
Disable JIT to find cause for random `PANIC: unprotected error in call to Lua API` on Travis (OS X).
- Factor out main_msg() in favor of mch_msg() and manual indentation, as to
  provide a much closer representation to the actual output of '--help'.
  'gcc -E' reveals that main_msg() only consists of 3 printf calls
  anyways.
- Factor out for loop used for printing top part of usage text; just
  print the text normally.

usage() text:
- Don't print the version; that's what '--version' is for.
- Be consistent about nomenclature, e.g. '<arg>' denotes required
  argument, '-h | --help' denotes '-h' and '--help' are equivalent, etc.
- Change some instances of vim{,rc,info} to nvim
While we're here:
- Remove references to the '+diff' feature, which has since been made
  non-optional.
- Update a few Vim instances with Nvim.
The systemlist test currently calls the `echo` command which can potentially
complete before being interrupted, causing random test failures.

Use `yes | xargs` instead. A `yes` invocation that is not piped through `xargs`
can produce a huge amount of lines in a very short time, leading memory
starvation when the result is being converted into a list. `xargs` ensures only
one line of output will be produced while allowing interrupt to be tested.
@benekastah
Copy link
Author

#1954 is this PR with a clean git history. Sorry for the confusion, but I couldn't fix the tons of extra commits this time around.

@benekastah benekastah closed this Feb 8, 2015
@jszakmeister jszakmeister removed the RFC label Feb 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Getting exit status from job with job-control