Skip to content

Commit

Permalink
Fix extensions crash on shutdown (#7075)
Browse files Browse the repository at this point in the history
The crash was happening due to the ExtensionWatcher thread still running
and attempting to call the watch() function,
while the extension was exiting.

Use the Initializer::shutdown() function so that all threads/services are stopped before
exiting.

Also update the documentation with the example extension.
  • Loading branch information
Smjert authored Apr 26, 2021
1 parent 7e2c72b commit f0881a6
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/wiki/development/osquery-sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ int main(int argc, char* argv[]) {

// Finally wait for a signal / interrupt to shutdown.
runner.waitForShutdown();
return 0;
return runner.shutdown(0);
}
```
Expand Down
2 changes: 1 addition & 1 deletion external/examples/config_plugin/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ int main(int argc, char* argv[]) {

// Finally wait for a signal / interrupt to shutdown.
runner.waitForShutdown();
return 0;
return runner.shutdown(0);
}
2 changes: 1 addition & 1 deletion external/examples/read_only_table/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ int main(int argc, char* argv[]) {

// Finally wait for a signal / interrupt to shutdown.
runner.waitForShutdown();
return 0;
return runner.shutdown(0);
}
2 changes: 1 addition & 1 deletion external/examples/writable_table/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,5 +306,5 @@ int main(int argc, char* argv[]) {

// Finally wait for a signal / interrupt to shutdown.
runner.waitForShutdown();
return 0;
return runner.shutdown(0);
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ int main(int argc, char* argv[]) {

// Finally wait for a signal / interrupt to shutdown.
runner.waitForShutdown();
return 0;
return runner.shutdown(0);
}

0 comments on commit f0881a6

Please sign in to comment.