porting some spawn functions