15,881,281 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by bjorn_ht (Top 9 by date)
bjorn_ht
27-Feb-12 5:29am
View
My knee jerk reaction here was exactly the same - I even think I made a comment alluding to that.
Still lots of software do exactly what the OP wants. There are a lot of scenarios where you want your process to start as a regular user process under a desktop user and you want to provide rudimentary protection for your process. Not necessarily protection from the user as such but from malicious software and from user errors.
For instance, kill all the processes that have systray icons on your own desktop and I bet you at least one of them starts up again by itself.
bjorn_ht
24-Feb-12 11:36am
View
I'm not talking about services, just regular processes you spawn with CreateProcess(). I agree that windows services is not the right thing here.
bjorn_ht
24-Feb-12 11:28am
View
Yes, the processes can be killed or die because you have a bug. The point with the watchdog is to make sure it starts again.
You can do that for instance by letting each process own a named mutex, then the other process can wait for that mutex and it knows the process died unexpetedly if the wait returns WAIT_ABANDONED.
So assuming you have N processes watching each other, then each would at startup
1. Try to obtain ownership of mutex "WATCHDOGMUTEX_n",
- If that fails, exit, watchdog n is already running
2. Call WaitForMultipleObjects on "WATCHHDOGMUTEX_~n" (so all except its own)
3. When that call returns, one of the other processes abandoned the mutex, i.e. died.
You are still vulnerable to programs that go after your processes, but so it should be.
bjorn_ht
24-Feb-12 11:19am
View
Yeah, this is the approach antivirus - and virus for that matter - often take. Even with the watchdog on the local system, you have fairly good protection against users in the task manager since it takes a while to kill a process there, so the remaining process(es) has ample time to restart the process that was killed before the user gets around to killing the next process.
bjorn_ht
24-Feb-12 10:16am
View
No "world class application" even attempts to prevent users from terminating the process.
bjorn_ht
20-Feb-12 14:21pm
View
Good luck!
bjorn_ht
19-Feb-12 15:12pm
View
I don't know if there is a windows equivalent to linux/unix select(). It could be you can make WaitForMultipleObjects or WSAWaitForMultipleObjects work.
Another option is to move the server logic to a background thread and only leave the console i/o in the main thread. That way you don't have to change the current server logic with the select() call, and you can just let the console i/o calls block since nothing else goes on in that thread.
bjorn_ht
17-Feb-12 6:12am
View
You should probably explain how you call your dll. Is it a plain C dll you load with [DllImport] attributes in the C# code, is it a managed C+ dll or something else?
bjorn_ht
17-Feb-12 5:29am
View
And pls ignore the calls to GetCurrentThreadId() in the printf() statements in MyThreadProc(). They don't belong there.
Show More