Beispiel #1
0
void
server_fill_environ(struct session *s, struct environ *env)
{
	char		 tmuxvar[MAXPATHLEN], *term;
	u_int		 idx;

	if (session_index(s, &idx) != 0)
		fatalx("session not found");
	xsnprintf(tmuxvar, sizeof tmuxvar,
	    "%s,%ld,%u", socket_path, (long) getpid(), idx);
	environ_set(env, "TMUX", tmuxvar);

	term = options_get_string(&s->options, "default-terminal");
	environ_set(env, "TERM", term);
}
Beispiel #2
0
spectgen_session_t *spectgen_session_get(unsigned int window_size,
					 scale_t scale,
					 unsigned int nbands,
					 spect_method_t method,
					 void *user_handle,
					 user_session_cb_t user_cb
			)
{
	spectgen_session_t *session = NULL;
	int ind = session_index(window_size);
	spectgen_session_t *i = NULL;
	pthread_mutex_lock(&session_hash_table_lock);
	i = session_hash_table[ind];
	while(i) {
		if(i->window_size == window_size &&
	           i->nbands == nbands &&
		   i->scale == scale &&
		   i->method == method) {
			pthread_mutex_lock(&i->lock);
			if(i->busy == 0) {
				i->busy = 1;
				session = i;
				pthread_mutex_unlock(&i->lock);
				break;
			}
			pthread_mutex_unlock(&i->lock);
		}
		i = i->next;
	}
	if(!session) {
		session = spectgen_session_create(window_size, scale, method, nbands);
		if(!session)
		      goto malloc_fail;
		session->next = session_hash_table[ind];
		session_hash_table[ind] = session;
	}
	session->user_cb = user_cb;
	session->user_handle = user_handle;
malloc_fail:
	pthread_mutex_unlock(&session_hash_table_lock);
	return session;
}