2020// USE OR OTHER DEALINGS IN THE SOFTWARE.
2121
2222#include "node_zos.h"
23+ #include "env-inl.h"
2324#include "node_internals.h"
2425#include "node_watchdog.h"
25- #include "env-inl.h"
2626
2727#include <pthread.h>
2828#include <signal.h>
4747namespace {
4848
4949uv_thread_t signalHandlerThread;
50- char * galtStack = nullptr;
50+ char* galtStack = nullptr;
5151
5252void __zosAtExit() {
5353 if (galtStack != nullptr) {
@@ -60,9 +60,9 @@ void __zosAtExit() {
6060namespace node {
6161
6262void zosDestroyThread() {
63- uv_queue_work(NULL, NULL, NULL, NULL );
63+ uv_queue_work(nullptr, nullptr, nullptr, nullptr );
6464 SigintWatchdogHelper::GetInstance()->Stop();
65- msgctl(uv_backend_fd(uv_default_loop()), IPC_RMID, NULL );
65+ msgctl(uv_backend_fd(uv_default_loop()), IPC_RMID, nullptr );
6666 // Tell zoslib that main process is terminating, for its diagnostics:
6767 __mainTerminating();
6868}
@@ -75,16 +75,15 @@ static void SignalHandlerThread(void* data) {
7575}
7676
7777void zosCreateSignalHandler() {
78- uv_thread_create(&signalHandlerThread, SignalHandlerThread, NULL );
78+ uv_thread_create(&signalHandlerThread, SignalHandlerThread, nullptr );
7979 // Block all signals on the main thread
8080 sigset_t set;
8181 sigfillset(&set);
82- CHECK_EQ(0, pthread_sigmask(SIG_BLOCK, &set, NULL ));
82+ CHECK_EQ(0, pthread_sigmask(SIG_BLOCK, &set, nullptr ));
8383}
8484
8585void zosCancelSignalHandler() {
86- if (pthread_cancel(signalHandlerThread) == -1)
87- abort();
86+ if (pthread_cancel(signalHandlerThread) == -1) abort();
8887}
8988
9089void zosSignalExit(int signo, siginfo_t* info, void* ucontext) {
@@ -93,9 +92,9 @@ void zosSignalExit(int signo, siginfo_t* info, void* ucontext) {
9392 struct sigaction new_action;
9493 new_action.sa_flags = SA_ONSTACK;
9594 new_action.sa_handler = SIG_DFL;
96- sigaction(signo, &new_action, NULL );
95+ sigaction(signo, &new_action, nullptr );
9796 if (signo == SIGABRT)
98- abort(); // from zoslib
97+ abort(); // from zoslib
9998 else
10099 raise(signo);
101100}
@@ -104,10 +103,10 @@ void zosIgnorePipeChildSignals() {
104103 struct sigaction new_action;
105104 new_action.sa_handler = SIG_IGN;
106105 sigfillset(&new_action.sa_mask);
107- sigaction(SIGPIPE, &new_action, NULL );
106+ sigaction(SIGPIPE, &new_action, nullptr );
108107 new_action.sa_handler = SIG_IGN;
109108 sigfillset(&new_action.sa_mask);
110- sigaction(SIGCHLD, &new_action, NULL );
109+ sigaction(SIGCHLD, &new_action, nullptr );
111110}
112111
113112static void RegisterProduct() {
@@ -119,56 +118,60 @@ static void RegisterProduct() {
119118
120119 std::string val;
121120 if (credentials::SafeGetenv("NODE_SMF89_REGISTRATION_VERBOSE", &val))
122- printf("Product registration data:\n"
123- "Product Name: %s\n"
124- "PID Name: %s\n"
125- "Major Version: %s\n"
126- "Product Owner: %s\n"
127- "Feature Name: %s\n", product_name.c_str(), pid.c_str(),
128- major_version.c_str(), product_owner.c_str(),
129- feature_name.c_str());
130-
131- unsigned long long rc =
132- __registerProduct(major_version.c_str(), product_owner.c_str(),
133- feature_name.c_str(), product_name.c_str(),
134- pid.c_str());
121+ printf("Product registration data:\n"
122+ "Product Name: %s\n"
123+ "PID Name: %s\n"
124+ "Major Version: %s\n"
125+ "Product Owner: %s\n"
126+ "Feature Name: %s\n",
127+ product_name.c_str(),
128+ pid.c_str(),
129+ major_version.c_str(),
130+ product_owner.c_str(),
131+ feature_name.c_str());
132+
133+ uint64_t rc = __registerProduct(major_version.c_str(),
134+ product_owner.c_str(),
135+ feature_name.c_str(),
136+ product_name.c_str(),
137+ pid.c_str());
135138
136139 if (rc && !credentials::SafeGetenv("NODE_SMF89_SUPPRESS_WARNING", &val)) {
137- fprintf(stderr, "WARNING: Could not register product with IFAUSAGE, "
138- "rc = %llu\n", rc);
139- if (const char* errorString = getIFAUsageErrorString(rc))
140- fprintf(stderr, "%s\n", errorString);
141-
142- fprintf(stderr,
143- "WARNING: Product usage data may not be collected. For more "
144- "details on the product registration data, set environment "
145- "variable NODE_SMF89_REGISTRATION_VERBOSE=1. To suppress this "
146- "warning message set the environment variable "
147- "NODE_SMF89_SUPPRESS_WARNING=1.\n");
140+ fprintf(stderr,
141+ "WARNING: Could not register product with IFAUSAGE, "
142+ "rc = %llu\n",
143+ rc);
144+ if (const char* errorString = getIFAUsageErrorString(rc))
145+ fprintf(stderr, "%s\n", errorString);
146+
147+ fprintf(stderr,
148+ "WARNING: Product usage data may not be collected. For more "
149+ "details on the product registration data, set environment "
150+ "variable NODE_SMF89_REGISTRATION_VERBOSE=1. To suppress this "
151+ "warning message set the environment variable "
152+ "NODE_SMF89_SUPPRESS_WARNING=1.\n");
148153 }
149154}
150155
151156ExitCode zosStart() {
152157 // Initialize environment variables in zoslib:
153- zoslib_config_t config {
154- .RUNTIME_LIMIT_ENVAR = "__NODERUNTIMELIMIT",
155- .CCSID_GUESS_BUF_SIZE_ENVAR = "__NODECCSIDGUESSBUFSIZE"
156- };
158+ zoslib_config_t config{
159+ .RUNTIME_LIMIT_ENVAR = "__NODERUNTIMELIMIT",
160+ .CCSID_GUESS_BUF_SIZE_ENVAR = "__NODECCSIDGUESSBUFSIZE"};
157161 if (__update_envar_names(&config) != 0) {
158162 return ExitCode::kGenericUserError;
159163 }
160164
161165 // Create an alternate stack for signal processing
162- const unsigned int STACK_SIZE = SIGSTKSZ + 1024* 1024;
166+ const unsigned int STACK_SIZE = SIGSTKSZ + 1024 * 1024;
163167 galtStack = (char*)malloc(STACK_SIZE);
164168 if (galtStack == nullptr) {
165169 return ExitCode::kGenericUserError;
166170 }
167171 stack_t ss = {.ss_sp = galtStack, .ss_size = STACK_SIZE, .ss_flags = 0};
168172 sigaltstack(&ss, 0);
169173
170- if (__doLogMemoryUsage())
171- atexit(__zosAtExit);
174+ if (__doLogMemoryUsage()) atexit(__zosAtExit);
172175
173176 return ExitCode::kNoFailure;
174177}
0 commit comments