aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortoni <matzeton@googlemail.com>2016-07-04 01:35:41 +0200
committertoni <matzeton@googlemail.com>2016-07-04 01:35:41 +0200
commit3a8e6b979f6a741342546622477d8bd4e8483cce (patch)
tree6cdf20f45b641e12b33fbd6d6464f4a9def6e9f5
parenta5026891c37cc19f27cc311252d7d5e8056bc337 (diff)
fixed SEM_UI post bug
-rw-r--r--src/main.c7
-rw-r--r--src/ui_elements.c17
2 files changed, 15 insertions, 9 deletions
diff --git a/src/main.c b/src/main.c
index f2a435d..916bf4d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -129,7 +129,6 @@ main(int argc, char **argv)
goto error;
}
- ui_ipc_sempost(SEM_UI);
if ((child = fork()) == 0) {
/* child */
logs("%s\n", "child");
@@ -158,14 +157,19 @@ main(int argc, char **argv)
}
} else if ( ui_ipc_msgcount(MQ_PW) > 0 ) {
ui_ipc_msgrecv(MQ_PW, pbuf);
+ logs("%s", "password, ");
ui_ipc_msgsend(MQ_IF, MSG(MSG_BUSY));
if (run_cryptcreate(pbuf, GETOPT(CRYPT_CMD).str) != 0) {
+ logs("%s", "cryptcreate error, ");
ui_ipc_msgsend(MQ_IF, MSG(MSG_CRYPTCMD_ERR));
} else {
+ logs("%s", "cryptcreate success, trywait SEM_UI, ");
ui_ipc_semtrywait(SEM_UI);
}
+ logs("%s", "wait SEM_IN, ");
ui_ipc_semwait(SEM_IN);
}
+ logs("%s", "wait SEM_BS, ");
ui_ipc_semwait(SEM_BS);
usleep(100000);
waitpid(child, &c_status, WNOHANG);
@@ -173,6 +177,7 @@ main(int argc, char **argv)
logs("%s\n", "child exited");
break;
}
+ logs("loop end (SEM_BS=%d, SEM_IN=%d, SEM_UI=%d).\n", ui_ipc_getvalue(SEM_BS), ui_ipc_getvalue(SEM_IN), ui_ipc_getvalue(SEM_UI));
}
logs("%s\n", "waiting for child");
wait(&c_status);
diff --git a/src/ui_elements.c b/src/ui_elements.c
index 535bc0c..f072d45 100644
--- a/src/ui_elements.c
+++ b/src/ui_elements.c
@@ -87,15 +87,16 @@ passwd_input_cb(WINDOW *wnd, void *data, int key)
ui_thrd_force_update();
sleep(2);
- ui_ipc_msgrecv(MQ_IF, ipc_buf);
-
- ui_thrd_suspend();
- set_txtwindow_color(infownd, COLOR_PAIR(4), COLOR_PAIR(4) | A_BOLD);
- set_txtwindow_title(infownd, "ERROR");
- set_txtwindow_text(infownd, ipc_buf);
- ui_thrd_resume();
- while (wgetch(stdscr) != '\n') { };
+ if (ui_ipc_msgcount(MQ_IF) > 0) {
+ ui_ipc_msgrecv(MQ_IF, ipc_buf);
+ ui_thrd_suspend();
+ set_txtwindow_color(infownd, COLOR_PAIR(4), COLOR_PAIR(4) | A_BOLD);
+ set_txtwindow_title(infownd, "ERROR");
+ set_txtwindow_text(infownd, ipc_buf);
+ ui_thrd_resume();
+ while (wgetch(stdscr) != '\n') { };
+ }
ui_thrd_suspend();
set_txtwindow_active(infownd, false);