exit

Memory leaks when using pthead_exit() to exit thread

孤人 提交于 2019-12-07 09:17:25
I have a problem when use pthread_exit() to exit .My code is like this: { ... pthread_attr_t attr; iRetValue = pthread_attr_init(&attr); iRetValue = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); size_t nStackSize = 4 * 1024 * 1024; iRetValue = pthread_attr_setstacksize(&attr, nStackSize); while(condition) { ... int32 iSockId = cServSocket.accept(); if(iSockId < 0) { continue; } pthread_t tid; int32* pSockId = new int(iSockId); iRetValue = pthread_create(&tid, &attr, run_thread, (void*)pSockId); ... } ... pthread_attr_destroy(&attr); } void* run_thread(void* p) { int32 iSockId =

Diagnosing an app that fails to halt

梦想的初衷 提交于 2019-12-07 06:41:43
问题 Our Windows app is often hanging in memory and I'm trying to use windbg to track down the problem. I'm very new to windbg and could use some advice (I have started to read Advanced Windows Debugging though). The app is a mix of C++ and COM objects written in VB. Occasionally when you exit, the app appears to go away but task manager shows it hanging around in memory, apparently idle. !threads shows me this: ThreadCount: 2 UnstartedThread: 0 BackgroundThread: 2 PendingThread: 0 DeadThread: 0

Code to stop execution of another code

瘦欲@ 提交于 2019-12-07 06:36:39
问题 I have a R code which does some data analysis and returns TRUE/FALSE . Sometimes, the input data is too large and the code just keeps running. I want a script that will monitor my data analysis code and if it doesn't return anything, in say 600 seconds , then it halts the running code and do something else. It will be like pressing STOP button on R console . I know about stop , break , exit , etc. But these won't be useful because code won't reach to these statements as it is still running

End SurfaceView and GameThread on exiting app

独自空忆成欢 提交于 2019-12-07 06:33:20
问题 I've got a surfaceview and a gameThread class. The gameThread keeps updating and painting on the SurfaceView class. Now when I exit the app (By pressing the home or back button) I get a message that the app force closed. That's because the GameThread still tries to draw on the erased surfaceview... So how do i properly end the app without getting this force close notification? I would like the GameThread class to stop when the back button is pressed. It should pause when pressing on home and

How to exit a flow?

末鹿安然 提交于 2019-12-07 05:21:07
问题 Once I've entered a Faces Flow, I want to exit it by going to any page that is not part of the flow. The problem is that the flow is not destroyed if I go outside, for example via an h:link . Indeed, if I click again on a h:commandButton whose action is the flowId, I go back to the previous flow instead of creating a new flow. How to exit a flow without having the user to click explicitly on a h:commandButton whose action corresponds to the return node of the flow ? Is it even possible ? Edit

macOS: Is there any way to know when the user has tried to quit an application via its Dock icon?

人盡茶涼 提交于 2019-12-07 03:13:04
问题 Is there any way for a Cocoa application to detect when the user has tried to quit it via its Dock menu, and not by some other method? Normally it's possible to catch and respond to quit events using the application delegate's applicationShouldTerminate: method. However, this method doesn't seem to distinguish between the request to quit coming from the application's main menu, from its Dock icon, from an Apple event, or any other conventional method of quitting the application. I'm curious

How to create a correct exit button in qt

强颜欢笑 提交于 2019-12-06 21:49:28
问题 I'm trying to create an exit button that correctly closes the GUI I have made in QT. I have tried doing this in the following way: #include <QtGui/QApplication> #include "mainwindow.h" int main(int argc, char *argv[]) { QApplication a(argc, argv); int window_width = QApplication::desktop()->width(); int window_height = QApplication::desktop()->height(); MainWindow w; QPushButton * quit_btn = new QPushButton; quit_btn->setParent(w.centralWidget()); quit_btn->setGeometry(window_width-50,12,32

C: Doing something when the program exits

守給你的承諾、 提交于 2019-12-06 20:56:32
问题 In C, if my application ends unexpectedly can I call a function before that happens? I'm writing a flag into a database (processRunning = 1) that prevents other applications from starting a similar process. When the application ends it would not change that flag back. 回答1: look into the atexit API of the C standard library. 回答2: On POSIX, the proper solution is to protect the data with a robust mutex in shared memory. If your process has died with a robust mutex held, another program trying

Is exit status observable behavior?

ε祈祈猫儿з 提交于 2019-12-06 18:26:14
问题 C 2018 5.1.2.3 6 says: The least requirements on a conforming implementation are: Accesses to volatile objects are evaluated strictly according to the rules of the abstract machine. At program termination, all data written into files shall be identical to the result that execution of the program according to the abstract semantics would have produced. The input and output dynamics of interactive devices shall take place as specified in 7.21.3. The intent of these requirements is that

Bind command to X-button of window title bar

杀马特。学长 韩版系。学妹 提交于 2019-12-06 15:01:00
问题 My WPF maintenance window have a toolbar with a button "Exit"; a CommandExit is bind with this button. The CommandExit perform some checks before exit. Now, if I click to close button of the window (x-button of title bar), this checks are ignored. How can I do to bind CommandExit to window x-button? 回答1: You have to implement event handler of your main window's event "Closing" where you can do checks and cancel the closing action. This is easiest way to do it, however otherwise you have to