summaryrefslogtreecommitdiffstats
path: root/generic/tclProcess.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2024-03-19 14:56:45 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2024-03-19 14:56:45 (GMT)
commit780e71600c142bee274fbf209304fb0ef2153143 (patch)
treebcfa89065ecea0a374bed505c235b77cba3db0a3 /generic/tclProcess.c
parent8925939c12d52f0c01b12796108f74ec08addd1b (diff)
downloadtcl-780e71600c142bee274fbf209304fb0ef2153143.zip
tcl-780e71600c142bee274fbf209304fb0ef2153143.tar.gz
tcl-780e71600c142bee274fbf209304fb0ef2153143.tar.bz2
Fix indentation/brace usage style issues
Diffstat (limited to 'generic/tclProcess.c')
-rw-r--r--generic/tclProcess.c121
1 files changed, 85 insertions, 36 deletions
diff --git a/generic/tclProcess.c b/generic/tclProcess.c
index 719f2e9..968e191 100644
--- a/generic/tclProcess.c
+++ b/generic/tclProcess.c
@@ -30,10 +30,11 @@ typedef struct ProcessInfo {
int purge; /* Purge eventualy. */
TclProcessWaitStatus status;/* Process status. */
int code; /* Error code, exit status or signal
- number. */
+ * number. */
Tcl_Obj *msg; /* Error message. */
Tcl_Obj *error; /* Error code. */
} ProcessInfo;
+
static Tcl_HashTable infoTablePerPid;
static Tcl_HashTable infoTablePerResolvedPid;
static int infoTablesInitialized = 0; /* 0 means not yet initialized. */
@@ -76,7 +77,7 @@ void
InitProcessInfo(
ProcessInfo *info, /* Structure to initialize. */
Tcl_Pid pid, /* Process id. */
- Tcl_Size resolvedPid) /* Resolved process id. */
+ Tcl_Size resolvedPid) /* Resolved process id. */
{
info->pid = pid;
info->resolvedPid = resolvedPid;
@@ -144,8 +145,7 @@ FreeProcessInfo(
int
RefreshProcessInfo(
ProcessInfo *info, /* Structure to refresh. */
- int options /* Options passed to WaitProcessStatus. */
-)
+ int options) /* Options passed to WaitProcessStatus. */
{
if (info->status == TCL_PROCESS_UNCHANGED) {
/*
@@ -154,8 +154,12 @@ RefreshProcessInfo(
info->status = WaitProcessStatus(info->pid, info->resolvedPid,
options, &info->code, &info->msg, &info->error);
- if (info->msg) Tcl_IncrRefCount(info->msg);
- if (info->error) Tcl_IncrRefCount(info->error);
+ if (info->msg) {
+ Tcl_IncrRefCount(info->msg);
+ }
+ if (info->error) {
+ Tcl_IncrRefCount(info->error);
+ }
return (info->status != TCL_PROCESS_UNCHANGED);
} else {
/*
@@ -192,8 +196,7 @@ WaitProcessStatus(
* - errno in case of error.
* - non-zero exit code for abormal exit.
* - signal number if killed or suspended.
- * - Tcl_WaitPid status in all other cases.
- */
+ * - Tcl_WaitPid status in all other cases. */
Tcl_Obj **msgObjPtr, /* If non-NULL, will receive error message. */
Tcl_Obj **errorObjPtr) /* If non-NULL, will receive error code. */
{
@@ -229,9 +232,13 @@ WaitProcessStatus(
msg = "child process lost (is SIGCHLD ignored or trapped?)";
}
- if (codePtr) *codePtr = errno;
- if (msgObjPtr) *msgObjPtr = Tcl_ObjPrintf(
- "error waiting for process to exit: %s", msg);
+ if (codePtr) {
+ *codePtr = errno;
+ }
+ if (msgObjPtr) {
+ *msgObjPtr = Tcl_ObjPrintf(
+ "error waiting for process to exit: %s", msg);
+ }
if (errorObjPtr) {
errorStrings[0] = Tcl_NewStringObj("POSIX", -1);
errorStrings[1] = Tcl_NewStringObj(Tcl_ErrnoId(), -1);
@@ -240,14 +247,20 @@ WaitProcessStatus(
}
return TCL_PROCESS_ERROR;
} else if (WIFEXITED(waitStatus)) {
- if (codePtr) *codePtr = WEXITSTATUS(waitStatus);
+ if (codePtr) {
+ *codePtr = WEXITSTATUS(waitStatus);
+ }
if (!WEXITSTATUS(waitStatus)) {
/*
* Normal exit.
*/
- if (msgObjPtr) *msgObjPtr = NULL;
- if (errorObjPtr) *errorObjPtr = NULL;
+ if (msgObjPtr) {
+ *msgObjPtr = NULL;
+ }
+ if (errorObjPtr) {
+ *errorObjPtr = NULL;
+ }
} else {
/*
* CHILDSTATUS pid code
@@ -255,8 +268,10 @@ WaitProcessStatus(
* Child exited with a non-zero exit status.
*/
- if (msgObjPtr) *msgObjPtr = Tcl_NewStringObj(
- "child process exited abnormally", -1);
+ if (msgObjPtr) {
+ *msgObjPtr = Tcl_NewStringObj(
+ "child process exited abnormally", -1);
+ }
if (errorObjPtr) {
errorStrings[0] = Tcl_NewStringObj("CHILDSTATUS", -1);
TclNewIntObj(errorStrings[1], resolvedPid);
@@ -273,9 +288,12 @@ WaitProcessStatus(
*/
msg = Tcl_SignalMsg(WTERMSIG(waitStatus));
- if (codePtr) *codePtr = WTERMSIG(waitStatus);
- if (msgObjPtr) *msgObjPtr = Tcl_ObjPrintf(
- "child killed: %s", msg);
+ if (codePtr) {
+ *codePtr = WTERMSIG(waitStatus);
+ }
+ if (msgObjPtr) {
+ *msgObjPtr = Tcl_ObjPrintf("child killed: %s", msg);
+ }
if (errorObjPtr) {
errorStrings[0] = Tcl_NewStringObj("CHILDKILLED", -1);
TclNewIntObj(errorStrings[1], resolvedPid);
@@ -292,9 +310,12 @@ WaitProcessStatus(
*/
msg = Tcl_SignalMsg(WSTOPSIG(waitStatus));
- if (codePtr) *codePtr = WSTOPSIG(waitStatus);
- if (msgObjPtr) *msgObjPtr = Tcl_ObjPrintf(
- "child suspended: %s", msg);
+ if (codePtr) {
+ *codePtr = WSTOPSIG(waitStatus);
+ }
+ if (msgObjPtr) {
+ *msgObjPtr = Tcl_ObjPrintf("child suspended: %s", msg);
+ }
if (errorObjPtr) {
errorStrings[0] = Tcl_NewStringObj("CHILDSUSP", -1);
TclNewIntObj(errorStrings[1], resolvedPid);
@@ -310,9 +331,13 @@ WaitProcessStatus(
* Child wait status didn't make sense.
*/
- if (codePtr) *codePtr = waitStatus;
- if (msgObjPtr) *msgObjPtr = Tcl_NewStringObj(
- "child wait status didn't make sense\n", -1);
+ if (codePtr) {
+ *codePtr = waitStatus;
+ }
+ if (msgObjPtr) {
+ *msgObjPtr = Tcl_NewStringObj(
+ "child wait status didn't make sense\n", -1);
+ }
if (errorObjPtr) {
errorStrings[0] = Tcl_NewStringObj("TCL", -1);
errorStrings[1] = Tcl_NewStringObj("OPERATION", -1);
@@ -815,7 +840,9 @@ TclProcessCreated(
info = (ProcessInfo *) Tcl_GetHashValue(entry);
entry2 = Tcl_FindHashEntry(&infoTablePerResolvedPid,
INT2PTR(resolvedPid));
- if (entry2) Tcl_DeleteHashEntry(entry2);
+ if (entry2) {
+ Tcl_DeleteHashEntry(entry2);
+ }
FreeProcessInfo(info);
}
@@ -886,9 +913,13 @@ TclProcessWait(
result = WaitProcessStatus(pid, TclpGetPid(pid), options, codePtr,
msgObjPtr, errorObjPtr);
- if (msgObjPtr && *msgObjPtr) Tcl_IncrRefCount(*msgObjPtr);
- if (errorObjPtr && *errorObjPtr) Tcl_IncrRefCount(*errorObjPtr);
- Tcl_MutexUnlock(&infoTablesMutex);
+ if (msgObjPtr && *msgObjPtr) {
+ Tcl_IncrRefCount(*msgObjPtr);
+ }
+ if (errorObjPtr && *errorObjPtr) {
+ Tcl_IncrRefCount(*errorObjPtr);
+ }
+ Tcl_MutexUnlock(&infoTablesMutex);
return result;
}
@@ -898,8 +929,8 @@ TclProcessWait(
* Process has completed but TclProcessWait has already been called,
* so report no change.
*/
- Tcl_MutexUnlock(&infoTablesMutex);
+ Tcl_MutexUnlock(&infoTablesMutex);
return TCL_PROCESS_UNCHANGED;
}
@@ -908,8 +939,8 @@ TclProcessWait(
/*
* No change, stop there.
*/
- Tcl_MutexUnlock(&infoTablesMutex);
+ Tcl_MutexUnlock(&infoTablesMutex);
return TCL_PROCESS_UNCHANGED;
}
@@ -918,11 +949,21 @@ TclProcessWait(
*/
result = info->status;
- if (codePtr) *codePtr = info->code;
- if (msgObjPtr) *msgObjPtr = info->msg;
- if (errorObjPtr) *errorObjPtr = info->error;
- if (msgObjPtr && *msgObjPtr) Tcl_IncrRefCount(*msgObjPtr);
- if (errorObjPtr && *errorObjPtr) Tcl_IncrRefCount(*errorObjPtr);
+ if (codePtr) {
+ *codePtr = info->code;
+ }
+ if (msgObjPtr) {
+ *msgObjPtr = info->msg;
+ }
+ if (errorObjPtr) {
+ *errorObjPtr = info->error;
+ }
+ if (msgObjPtr && *msgObjPtr) {
+ Tcl_IncrRefCount(*msgObjPtr);
+ }
+ if (errorObjPtr && *errorObjPtr) {
+ Tcl_IncrRefCount(*errorObjPtr);
+ }
if (autopurge) {
/*
@@ -945,3 +986,11 @@ TclProcessWait(
Tcl_MutexUnlock(&infoTablesMutex);
return result;
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */