reboot() error: Cannot fork? - Minix

This is a discussion on reboot() error: Cannot fork? - Minix ; I am happily writing my can_driver and getting it to install.. however.. I cannot seem to shut it down.. I have tried using the "service down [pid]" command without any success..(I just get an unknown (-3) error).. When I do ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: reboot() error: Cannot fork?

  1. reboot() error: Cannot fork?

    I am happily writing my can_driver and getting it to install..

    however.. I cannot seem to shut it down.. I have tried using the
    "service down [pid]" command without any success..(I just get an
    unknown (-3) error)..

    When I do a reboot().. this is the reaction....



    ...... (more that can be displayed)...
    Uncaught Msg! num = -38
    Uncaught Msg! num = -38
    Uncaught Msg! num = -38
    Uncaught Msg! num = -38
    PM can't reply to 71114 (can_driver)
    PM panic in CAN104: Sigaction failed: 109
    SYSTEM, reply to 71114 failed: -109
    *Usage: nonamed [-qs] [-d[level]] [-p port]
    Panic in CMOS: sending reply failed: -105
    SYSTEM, reply to 35563 failed: -109
    unknown error: reboot()
    -- after pressing enter--
    * shutdown
    Cannot fork
    #


    At this stage I need to cycle the power to restart....

    Can anyone point out a stupid error on my behalf? or is there something
    really wrong?

    I would like to point out at this stage that the Minix3 kernel is
    supposed to be impervious to driver code faults... am I just really
    clever, or have I breached some law?


    some of my driver code...if you think you know what is happening and
    want more code.. let me know...

    void main (void)
    ....
    initialization stuff... works OK.. I think..
    ....
    while (TRUE)
    {
    receive(ANY, &sysmsg);
    if (sigaction(SIGTERM,&sa,NULL)<0)
    {
    panic("CAN104","sigaction failed", errno);
    can_sig_stop();
    }
    caller = sysmsg.m_source;
    proc_nr =sysmsg.IO_ENDPT;

    /* check message and do action.. */

    switch(sysmsg.m_type)
    {
    case DEV_PING: notify(sysmsg.m_source); break;
    case DEV_OPEN: r = can_open(); break;
    case DEV_CLOSE: r = can_close(); break;
    case DEV_IOCTL: r = can_io_ctl(&sysmsg); break;
    case DEV_READ: r = can_read(&sysmsg); break;
    case DEV_WRITE: r = can_write(&sysmsg); break;
    case DEV_STATUS: r = can_drv_status(); break;
    case CANCEL: sys_exit(0);
    case HARD_INT: can_hard_int(&sysmsg); continue;
    case SYS_SIG: can_sig_stop(); continue;
    default: printf("Uncaught Msg! num = %d\n", sysmsg.m_type); r =
    EINVAL;
    }

    /* Prepare and send reply message */
    if (sysmsg.m_type != DEV_PING)
    reply(DEV_REPLY, caller, proc_nr, r);
    }

    }


  2. Re: reboot() error: Cannot fork?

    On 17 Jan 2007 18:14:44 -0800, dave373 wrote:
    > I am happily writing my can_driver and getting it to install..
    >
    > however.. I cannot seem to shut it down.. I have tried using the
    > "service down [pid]" command without any success..(I just get an
    > unknown (-3) error)..
    >
    > When I do a reboot().. this is the reaction....
    >
    >
    >
    > ..... (more that can be displayed)...
    > Uncaught Msg! num = -38
    > Uncaught Msg! num = -38
    > Uncaught Msg! num = -38
    > Uncaught Msg! num = -38
    > PM can't reply to 71114 (can_driver)
    > PM panic in CAN104: Sigaction failed: 109
    > SYSTEM, reply to 71114 failed: -109
    > *Usage: nonamed [-qs] [-d[level]] [-p port]
    > Panic in CMOS: sending reply failed: -105
    > SYSTEM, reply to 35563 failed: -109
    > unknown error: reboot()
    > -- after pressing enter--
    > * shutdown
    > Cannot fork
    > #
    >
    >
    > At this stage I need to cycle the power to restart....
    >
    > Can anyone point out a stupid error on my behalf? or is there something
    > really wrong?
    >
    > I would like to point out at this stage that the Minix3 kernel is
    > supposed to be impervious to driver code faults... am I just really
    > clever, or have I breached some law?
    >
    >
    > some of my driver code...if you think you know what is happening and
    > want more code.. let me know...
    >
    > void main (void)
    > ...
    > initialization stuff... works OK.. I think..
    > ...
    > while (TRUE)
    > {
    > receive(ANY, &sysmsg);
    > if (sigaction(SIGTERM,&sa,NULL)<0)
    > {
    > panic("CAN104","sigaction failed", errno);
    > can_sig_stop();
    > }
    > caller = sysmsg.m_source;
    > proc_nr =sysmsg.IO_ENDPT;
    >
    > /* check message and do action.. */
    >
    > switch(sysmsg.m_type)
    > {
    > case DEV_PING: notify(sysmsg.m_source); break;
    > case DEV_OPEN: r = can_open(); break;
    > case DEV_CLOSE: r = can_close(); break;
    > case DEV_IOCTL: r = can_io_ctl(&sysmsg); break;
    > case DEV_READ: r = can_read(&sysmsg); break;
    > case DEV_WRITE: r = can_write(&sysmsg); break;
    > case DEV_STATUS: r = can_drv_status(); break;
    > case CANCEL: sys_exit(0);
    > case HARD_INT: can_hard_int(&sysmsg); continue;
    > case SYS_SIG: can_sig_stop(); continue;
    > default: printf("Uncaught Msg! num = %d\n", sysmsg.m_type); r =
    > EINVAL;
    > }
    >
    > /* Prepare and send reply message */
    > if (sysmsg.m_type != DEV_PING)
    > reply(DEV_REPLY, caller, proc_nr, r);
    > }
    >
    > }
    >


  3. Re: reboot() error: Cannot fork?

    All,

    Oops, sorry about my last quote-only posting, not sure how that
    happened..

    >> When I do a reboot().. this is the reaction....
    >>
    >>
    >>
    >> ..... (more that can be displayed)...
    >> Uncaught Msg! num = -38
    >> Uncaught Msg! num = -38
    >> Uncaught Msg! num = -38
    >> Uncaught Msg! num = -38


    It's possible that receive() is returning an error, without doing
    receive(), making your driver loop forever and sending infinite amounts
    of messages to whatever happened to be in m_source.

    >> PM can't reply to 71114 (can_driver)
    >> PM panic in CAN104: Sigaction failed: 109
    >> SYSTEM, reply to 71114 failed: -109


    Whoever got a message from reply() tried to reply to it,
    but that doesn't work because receive() does nothing
    and after that, you panic() becuase the sigaction() failed,
    if my receive() hypothesis is correct.

    The reboot doesn't work because the shell can't fork()
    because PM has panic()ed.

    >> At this stage I need to cycle the power to restart....
    >>
    >> Can anyone point out a stupid error on my behalf? or is there something
    >> really wrong?
    >>
    >> I would like to point out at this stage that the Minix3 kernel is
    >> supposed to be impervious to driver code faults... am I just really
    >> clever, or have I breached some law?


    The kernel is still fine - everything is still running admittedly a
    system without PM is not very useful. And admittedly the system
    currently can not deal well with processes that 'sabotage' the
    messaging protocol (e.g. by not replying or by sending a message
    without doing receive() or by exiting before doing a receive(),
    causing, in the case of PM, a panic).

    >> some of my driver code...if you think you know what is happening and
    >> want more code.. let me know...


    The first step is to check the receive() return code, and print
    debugging messages about from whom you got that unhandled message,
    and to whom you are sending a reply().

    =Ben



  4. Re: reboot() error: Cannot fork?


    Ben Gras wrote:


    > The first step is to check the receive() return code, and print
    > debugging messages about from whom you got that unhandled message,
    > and to whom you are sending a reply().
    >
    > =Ben


    OK, the message is coming from 0, (pm)..
    with some code modifications, I now can shutdown OK, however, I am
    still getting the -38 message.. any idea on what that message might be?
    I have searched the code and can't find where it is defined...

    Thanks for the help...

    Dave


+ Reply to Thread