BEGIN_C_DECLS
void osm_console(osm_opensm_t *p_osm);
+void osm_console_prompt(void);
END_C_DECLS
/****v* OpenSM/osm_exit_flag
*/
-extern volatile int osm_exit_flag;
+extern volatile unsigned int osm_exit_flag;
/*
* DESCRIPTION
* Set to one to cause all threads to leave
*********/
-#ifndef __WIN__
-/****f* OpenSM: OpenSM/osm_reg_sig_handler
-* NAME
-* osm_reg_sig_handler
-*
-* DESCRIPTION
-* Registers the common signal handler
-*
-* SYNOPSIS
-*/
-void osm_reg_sig_handler(
-IN osm_opensm_t* const p_osm);
-/*
-* PARAMETERS
-* p_osm
-* [in] Pointer to a OpenSM object to handle signals on.
-*
-* RETURN VALUES
-* None
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-#endif /* __WIN__ */
-
END_C_DECLS
#endif /* _OSM_OPENSM_H_ */
instantiating more than one opensm object.
*/
osm_opensm_t osm;
-volatile int osm_exit_flag = 0;
+volatile unsigned int osm_exit_flag = 0;
#define GUID_ARRAY_SIZE 64
#define INVALID_GUID (0xFFFFFFFFFFFFFFFFULL)
#define _GNU_SOURCE /* for getline */
#include <stdio.h>
#include <stdlib.h>
+#include <sys/poll.h>
#include <opensm/osm_console.h>
#define OSM_COMMAND_LINE_LEN 120
}
}
+void osm_console_prompt(void)
+{
+ printf("%s", OSM_COMMAND_PROMPT);
+ fflush(stdout);
+}
+
void osm_console(osm_opensm_t *p_osm)
{
+ struct pollfd pollfd;
char *p_line;
size_t len;
ssize_t n;
- printf("\nOpenSM Console\n\n");
- while (1) {
- printf("%s", OSM_COMMAND_PROMPT);
+ pollfd.fd = 0;
+ pollfd.events = POLLIN;
+ pollfd.revents = 0;
+
+ if (poll(&pollfd, 1, 10000) <= 0)
+ return;
+
+ if (pollfd.revents|POLLIN) {
p_line = NULL;
/* Get input line */
n = getline(&p_line, &len, stdin);
printf("Input error\n");
fflush(stdin);
}
+ osm_console_prompt();
}
}
#include <stdio.h>
#include <stdlib.h>
#include <complib/cl_memory.h>
-#include <complib/cl_signal_osd.h>
#include <opensm/cl_dispatcher.h>
#include <complib/cl_passivelock.h>
#include <vendor/osm_vendor_api.h>
OSM_LOG_EXIT( &p_osm->log );
}
-/**********************************************************************
- * SHUT DOWN IS CONTROLLED BY A GLOBAL EXIT FLAG
- **********************************************************************/
-#ifndef __WIN__
-static osm_opensm_t *__p_osm_to_signal;
-
-void
-__sig_handler(
- int signum )
-{
- static int got_signal = 0;
-
- if( signum != SIGHUP )
- {
- if( !got_signal )
- {
- got_signal++;
- printf( "OpenSM: Got signal %d - exiting...\n", signum );
- osm_exit_flag = 1;
- }
- }
- else
- {
- /* a HUP signal should only start a new heavy sweep */
- __p_osm_to_signal->subn.force_immediate_heavy_sweep = TRUE;
- osm_state_mgr_process( &__p_osm_to_signal->sm.state_mgr,
- OSM_SIGNAL_SWEEP );
- }
-}
-
-void
-osm_reg_sig_handler(
- IN osm_opensm_t * const p_osm )
-{
- __p_osm_to_signal = p_osm;
-#ifndef OSM_VENDOR_INTF_OPENIB
- cl_reg_sig_hdl( SIGINT, __sig_handler );
-#endif
- cl_reg_sig_hdl( SIGTERM, __sig_handler );
- cl_reg_sig_hdl( SIGHUP, __sig_handler );
- osm_exit_flag = 0;
-
- return;
-}
-#endif /* __WIN__ */
-
/**********************************************************************
**********************************************************************/
ib_api_status_t
#include <complib/cl_passivelock.h>
#include <complib/cl_debug.h>
#include <iba/ib_types.h>
-#include <complib/cl_signal_osd.h>
#include <opensm/osm_sm.h>
#include <opensm/osm_madw.h>
#include <opensm/osm_log.h>
if( p_sm->thread_state == OSM_THREAD_STATE_INIT )
{
- osm_log( p_sm->p_log, OSM_LOG_DEBUG,
- "__osm_sm_sweeper: " "Masking ^C Signals\n" );
- cl_sig_mask_sigint( );
-
p_sm->thread_state = OSM_THREAD_STATE_RUN;
}
#endif /* HAVE_CONFIG_H */
#include <iba/ib_types.h>
-#include <complib/cl_signal_osd.h>
#include <complib/cl_memory.h>
#include <opensm/osm_vl15intf.h>
#include <opensm/osm_madw.h>
if ( p_vl->thread_state == OSM_THREAD_STATE_NONE)
{
- cl_sig_mask_sigint( );
p_vl->thread_state = OSM_THREAD_STATE_RUN;
}