asyncrun.vim
asyncrun.vim copied to clipboard
Is there a method for the terminal window to also receive the "segmentation fault (core dumped) ./a.exe" message?
I found that if the segmentation fault occurred because of my bad code, the terminal window does not receive or display this information. Is there a method to address this issue?
#include <iostream>
class DerivedA {
public:
~DerivedA() { delete this; };
};
class DerivedB {};
int main() {
[[maybe_unused]] DerivedA a;
return 0;
}
So what's wrong with this plugin? What command do you use?
So what's wrong with this plugin? What command do you use?
I have tried both AsyncRun! -mode=term g++ ./a.cpp -o a.exe && ./a.exe and AsyncRun! -mode=async g++ ./a.cpp -o a.exe && ./a.exe. In theory, the output window should display [1] 3546 segmentation fault (core dumped) ./a.exe due to a double deletion in my code. However, nothing appears in the Vim output window. Is there a method to make the output window capture and display the segmentation fault information?
So what's wrong with this plugin? What command do you use?
My async configuration:
let g:asyncrun_bell = 1
let g:asyncrun_save = 1
let g:asyncrun_mode = 'term'
Perhaps I know why the terminal doesn't receive "segmentation fault (core dumped) ./a.exe".
Recently, I have been learning about multi-process programs. If the parent process terminates before the child process, any messages sent by the child process may not be received by the terminal. This happens because the child's parent process ID (PPID) is reassigned to the init process, preventing the terminal from receiving its messages.
The following code example demonstrates this behavior:
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
int main() {
int pid;
pid = fork();
/* Child process */
if( pid == 0 ) {
sleep( 1 );
printf( "Child: pid is %d and ppid is %d\n", getpid(), getppid() );
} else { /* Parent process */
// sleep(1);
printf( "Parent: pid is %d and ppid is %d\n", getpid(), getppid() );
}
return 0;
}
However, the strange thing is that AsyncRun! -mode=async g++ ./a.cpp -o a.exe && ./a.exe can receive the complete output from the above code but does not receive [1] 3546 segmentation fault (core dumped) ./a.exe.
However, the strange thing is that
AsyncRun! -mode=async g++ ./a.cpp -o a.exe && ./a.execan receive the complete output from the above code but does not receive[1] 3546 segmentation fault (core dumped) ./a.exe.
Quickfix can receive the complete output from the above code but does not receive [1] 3546 segmentation fault (core dumped) ./a.exe.
Term cannot receive either the complete output from the above code or [1] 3546 segmentation fault (core dumped) ./a.exe.