ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
April 17th, 2024 | 14:30-16:00 SGT (UTC+8) | Online

Wireshark-bugs: [Wireshark-bugs] [Bug 2592] Ctrl-C does not stop "dumpcap -S"

Date: Thu, 19 Jun 2008 13:54:46 -0700 (PDT)
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=2592


Abhik Sarkar <sarkar.abhik@xxxxxxxxx> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sarkar.abhik@xxxxxxxxx




--- Comment #1 from Abhik Sarkar <sarkar.abhik@xxxxxxxxx>  2008-06-19 13:54:45 PDT ---
Looking at dumpcap.c, I don't think the problem could happen on non-Win32
platforms(I have only Win32, so can't be sure). However, on Windows it seems to
be by design because of some restrictions... if we look at capture_cleanup (for
windows):

<quote>
       If we're not running as a capture child, we might be running as
       a service; ignore CTRL_LOGOFF_EVENT, so we keep running after the
       user logs out.  (XXX - can we explicitly check whether we're
       running as a service?) */
...
    /* Keep capture running if we're a service and a user logs off */
    if (capture_child || (dwCtrlType != CTRL_LOGOFF_EVENT)) {
        capture_loop_stop();
        return TRUE;
    } else {
        return FALSE;
    }
</quote>

If "dumpcap -S" is started directly in a terminal, capture_child will be false,
and the signal handler will hence always return a FALSE... resulting in the
program not exiting on a ctrl-C.

I can see only two solutions:
1- We make it possible to determine if dumpcap is indeed running as a service
or not. Possible solutions:
 - Pass a unique command line argument only when starting as a service
 - Perhaps this link has the answer: 
   http://marc.info/?l=openssl-dev&m=104401851331452&w=2
2- Perhaps a quick hack for now (unless this will have any side effects), have
print_statistics as a static variable and change 
if (capture_child || (dwCtrlType != CTRL_LOGOFF_EVENT)) {
to
if (capture_child || (dwCtrlType != CTRL_LOGOFF_EVENT) || print_statistics) {


-- 
Configure bugmail: https://bugs.wireshark.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.