Not sure standard this is for BSDs other than FreeBSD (only tested on FreeBSD 10.0, amd64). Took a lot of picking apart the source code ps, and other than just using a system library, it doing the same thing that Mikhail T.'s solution is doing. Though despite, the code being pretty rough (sort got caught up in figuring out how to do this 'properly' because 'it really shouldn't be that hard, right?', and 2+ hours later, this is what I have. Works wonderfully.
Remember to compile using the -lkvm flag to pull in libkvm (Kernel Data Library). The kinfo_proc is detailed in /usr/include/sys/user.h and has ever bit of information you ever wanted to know about a process. The example code below uses the current process, but it is just pulling the information based on PID. I've got in my scrap pieces of code what you need to pull out the process's environment variables and other stuff, just tell me if you want.
#include <fcntl.h>
#include <kvm.h>
#include <sys/sysctl.h>
#include <sys/user.h>
#include <unistd.h>
#include <stdio.h>
#include <time.h>
int main(int argc,char** args) {
kvm_t* kd;
// Get a handle to libkvm interface
kd = kvm_open(NULL, "/dev/null", NULL, O_RDONLY, "error: ");
pid_t pid;
pid = getpid();
struct kinfo_proc * kp;
int p_count;
// Get the kinfo_proc for this process by its pid
kp = kvm_getprocs(kd, KERN_PROC_PID, pid, &p_count);
printf("got %i kinfo_proc for pid %i\n", p_count, pid);
time_t proc_start_time;
proc_start_time = kp->ki_start.tv_sec;
kvm_close(kd);
printf("Process started at %s\n", ctime(&proc_start_time));
return 0;
}
edit
Full source code for example including FreeBSD, NetBSD and Mac OS X (OpenBSD when I get a chance) can be found here: https://github.com/dnabre/misc/tree/master/proc_info